123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?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('users', function (Blueprint $table) {
- $table->comment('用户信息表');
- $table->id()->comment('用户ID');
- $table->string('name')->unique()->comment('用户账号');
- $table->string('email')->nullable()->comment('用户邮箱');
- $table->timestamp('email_verified_at')->nullable()->comment('验证邮箱');
- $table->string('password')->comment('用户密码');
- $table->string('nickname')->nullable()->comment('用户昵称');
- $table->string('avatar')->nullable()->comment('用户头像');
- $table->string('mobile')->nullable()->comment('手机号码');
- $table->tinyInteger('sex')->default(0)->nullable()->comment('性别');
- $table->string('ip_address', 45)->nullable()->comment('最后登录IP');
- $table->timestamp('last_activity_at')->nullable()->comment('最后登录时间');
- $table->text('remark')->nullable()->comment('备注');
- $table->tinyInteger('status')->default(0)->comment('账户状态 (0正常 1停用)');
- $table->bigInteger('creator')->nullable()->comment('创建者');
- $table->bigInteger('updater')->nullable()->comment('更新者');
- $table->rememberToken();
- $table->timestamps();
- });
- Schema::create('password_reset_tokens', function (Blueprint $table) {
- $table->string('name')->primary();
- $table->string('token');
- $table->timestamp('created_at')->nullable();
- });
- Schema::create('sessions', function (Blueprint $table) {
- $table->string('id')->primary();
- $table->foreignId('user_id')->nullable()->index();
- $table->string('ip_address', 45)->nullable();
- $table->text('user_agent')->nullable();
- $table->longText('payload');
- $table->integer('last_activity')->index();
- });
- }
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('users');
- Schema::dropIfExists('password_reset_tokens');
- Schema::dropIfExists('sessions');
- }
- };
|