| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- return new class extends Migration {
- public function up(): void
- {
- if (!Schema::hasColumn('agents', 'owner_user_id')) {
- Schema::table('agents', fn (Blueprint $t) => $t->unsignedBigInteger('owner_user_id')->nullable()->unique());
- }
- if (Schema::hasTable('agent_applications')) return;
- Schema::create('agent_applications', function (Blueprint $t) {
- $t->id();
- $t->unsignedBigInteger('user_id')->index();
- $t->string('username', 64);
- $t->unsignedBigInteger('pending_user_id')->nullable()->unique();
- $t->string('pending_username', 64)->nullable()->unique();
- $t->string('password_hash')->nullable();
- $t->string('withdraw_password_hash')->nullable();
- $t->string('status', 16)->default('pending')->index();
- $t->unsignedBigInteger('agent_id')->nullable()->unique();
- $t->string('reject_reason', 500)->default('');
- $t->unsignedBigInteger('reviewed_by')->nullable();
- $t->dateTime('reviewed_at')->nullable();
- $t->timestamps();
- });
- }
- public function down(): void
- {
- // Keep reviewed identity links and application history on a code rollback.
- }
- };
|