2026_10_29_140000_create_agent_applications.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration {
  6. public function up(): void
  7. {
  8. if (!Schema::hasColumn('agents', 'owner_user_id')) {
  9. Schema::table('agents', fn (Blueprint $t) => $t->unsignedBigInteger('owner_user_id')->nullable()->unique());
  10. }
  11. if (Schema::hasTable('agent_applications')) return;
  12. Schema::create('agent_applications', function (Blueprint $t) {
  13. $t->id();
  14. $t->unsignedBigInteger('user_id')->index();
  15. $t->string('username', 64);
  16. $t->unsignedBigInteger('pending_user_id')->nullable()->unique();
  17. $t->string('pending_username', 64)->nullable()->unique();
  18. $t->string('password_hash')->nullable();
  19. $t->string('withdraw_password_hash')->nullable();
  20. $t->string('status', 16)->default('pending')->index();
  21. $t->unsignedBigInteger('agent_id')->nullable()->unique();
  22. $t->string('reject_reason', 500)->default('');
  23. $t->unsignedBigInteger('reviewed_by')->nullable();
  24. $t->dateTime('reviewed_at')->nullable();
  25. $t->timestamps();
  26. });
  27. }
  28. public function down(): void
  29. {
  30. // Keep reviewed identity links and application history on a code rollback.
  31. }
  32. };