Update role stacking

This commit is contained in:
DariusIII
2025-11-30 03:10:46 +01:00
parent 49b4e97092
commit a58bd7f435
10 changed files with 1020 additions and 21 deletions
@@ -0,0 +1,30 @@
<?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::table('users', function (Blueprint $table) {
$table->datetime('pending_role_start_date')->nullable()->after('rolechangedate')->comment('When the pending role change takes effect');
$table->integer('pending_roles_id')->nullable()->after('pending_role_start_date')->comment('The role that will be applied after current role expires');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['pending_role_start_date', 'pending_roles_id']);
});
}
};
@@ -0,0 +1,40 @@
<?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('user_role_history', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->index();
$table->integer('old_role_id')->nullable();
$table->integer('new_role_id');
$table->datetime('old_expiry_date')->nullable()->comment('Previous role expiry date');
$table->datetime('new_expiry_date')->nullable()->comment('New role expiry date');
$table->datetime('effective_date')->comment('When this role change became active');
$table->boolean('is_stacked')->default(false)->comment('Was this role stacked after previous expiry');
$table->string('change_reason')->nullable()->comment('Reason for role change (upgrade, downgrade, expiry, admin, etc)');
$table->unsignedBigInteger('changed_by')->nullable()->comment('Admin user ID who made the change');
$table->timestamps();
// Note: Foreign key constraint removed due to potential schema conflicts
// Ensure referential integrity at application level
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_role_history');
}
};