mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Add account promotions support
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('role_promotions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->json('applicable_roles')->comment('JSON array of role IDs this promotion applies to');
|
||||
$table->integer('additional_days')->default(0)->comment('Additional days added to role expiry');
|
||||
$table->date('start_date')->nullable()->comment('Promotion start date');
|
||||
$table->date('end_date')->nullable()->comment('Promotion end date');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('role_promotions');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('role_promotion_stats', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->unsignedBigInteger('role_promotion_id');
|
||||
$table->unsignedBigInteger('role_id');
|
||||
$table->integer('days_added')->comment('Number of days added to role expiry');
|
||||
$table->dateTime('previous_expiry_date')->nullable()->comment('Previous role expiry date before promotion');
|
||||
$table->dateTime('new_expiry_date')->nullable()->comment('New role expiry date after promotion');
|
||||
$table->timestamp('applied_at')->comment('When the promotion was applied');
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign key constraints
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('role_promotion_id')->references('id')->on('role_promotions')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
|
||||
|
||||
// Indexes for performance
|
||||
$table->index('user_id');
|
||||
$table->index('role_promotion_id');
|
||||
$table->index('role_id');
|
||||
$table->index('applied_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('role_promotion_stats');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user