| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- use Illuminate\Support\Facades\Hash; // 添加这个
- use Illuminate\Support\Facades\DB; // 添加这个
- return new class extends Migration
- {
- /**
- * Run the migrations.
- */
- public function up(): void
- {
- Schema::create('admin', function (Blueprint $table) {
- $table->id();
- $table->string('account', 50)->unique()->comment('账号'); // 账号,唯一
- $table->string('nickname', 50)->comment('昵称'); // 昵称
- $table->string('password')->comment('密码'); // 密码
- $table->tinyInteger('status')->default(1)->comment('状态:0-禁用,1-启用'); // 状态
- $table->timestamps();
- $table->index('account');
- $table->index('status');
- });
- // 在表创建后插入超级管理员数据
- DB::table('admin')->insert([
- 'account' => 'admin',
- 'nickname' => '超级管理员',
- 'password' => Hash::make('123456'), // 请修改这个默认密码
- 'status' => 1,
- 'created_at' => now(),
- 'updated_at' => now(),
- ]);
- }
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('admin');
- }
- };
|