0001_01_01_000000_create_users_table.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('users', function (Blueprint $table) {
  13. $table->id();
  14. $table->string('name');
  15. $table->string('email')->unique();
  16. $table->string('phone')->nullable();
  17. $table->timestamp('email_verified_at')->nullable();
  18. $table->string('password');
  19. $table->string('role');
  20. $table->rememberToken();
  21. $table->timestamps();
  22. });
  23. Schema::create('password_reset_tokens', function (Blueprint $table) {
  24. $table->string('email')->primary();
  25. $table->string('token');
  26. $table->timestamp('created_at')->nullable();
  27. });
  28. Schema::create('sessions', function (Blueprint $table) {
  29. $table->string('id')->primary();
  30. $table->foreignId('user_id')->nullable()->index();
  31. $table->string('ip_address', 45)->nullable();
  32. $table->text('user_agent')->nullable();
  33. $table->longText('payload');
  34. $table->integer('last_activity')->index();
  35. });
  36. }
  37. /**
  38. * Reverse the migrations.
  39. */
  40. public function down(): void
  41. {
  42. Schema::dropIfExists('users');
  43. Schema::dropIfExists('password_reset_tokens');
  44. Schema::dropIfExists('sessions');
  45. }
  46. };