0001_01_01_000000_create_system_users_table.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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('system_users', function (Blueprint $table) {
  13. $table->comment('用户信息表');
  14. $table->id()->comment('用户ID');
  15. $table->string('name')->unique()->comment('用户账号');
  16. $table->string('email')->nullable()->comment('用户邮箱');
  17. $table->timestamp('email_verified_at')->nullable()->comment('验证邮箱');
  18. $table->string('password')->comment('用户密码');
  19. $table->string('nickname')->nullable()->comment('用户昵称');
  20. $table->string('avatar')->nullable()->comment('用户头像');
  21. $table->string('mobile')->nullable()->comment('手机号码');
  22. $table->tinyInteger('sex')->default(0)->nullable()->comment('性别');
  23. $table->string('ip_address', 45)->nullable()->comment('最后登录IP');
  24. $table->timestamp('last_activity_at')->nullable()->comment('最后登录时间');
  25. $table->text('remark')->nullable()->comment('备注');
  26. $table->tinyInteger('status')->default(0)->comment('账户状态 (0正常 1停用)');
  27. $table->bigInteger('creator')->nullable()->comment('创建者');
  28. $table->bigInteger('updater')->nullable()->comment('更新者');
  29. $table->rememberToken();
  30. $table->timestamps();
  31. $table->softDeletes();
  32. });
  33. Schema::create('system_password_reset_tokens', function (Blueprint $table) {
  34. $table->string('name')->primary();
  35. $table->string('token');
  36. $table->timestamp('created_at')->nullable();
  37. });
  38. Schema::create('system_sessions', function (Blueprint $table) {
  39. $table->string('id')->primary();
  40. $table->foreignId('user_id')->nullable()->index();
  41. $table->string('ip_address', 45)->nullable();
  42. $table->text('user_agent')->nullable();
  43. $table->longText('payload');
  44. $table->integer('last_activity')->index();
  45. });
  46. }
  47. /**
  48. * Reverse the migrations.
  49. */
  50. public function down(): void
  51. {
  52. Schema::dropIfExists('system_users');
  53. Schema::dropIfExists('system_password_reset_tokens');
  54. Schema::dropIfExists('system_sessions');
  55. }
  56. };