study-api-v2/database/migrations/2024_01_01_000001_create_student_table.php

58 lines
2.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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('student', function (Blueprint $table) {
$table->id();
$table->string('username', 200)->unique()->comment('用户名');
$table->string('real_name', 30)->nullable()->comment('真实姓名');
$table->string('password', 100)->comment('密码');
$table->char('salt', 6)->default('')->comment('随机串');
$table->unsignedInteger('role')->default(0)->comment('所属角色; 2学生 3家长');
$table->unsignedInteger('grade_id')->default(0)->comment('年级id');
$table->unsignedInteger('parent_id')->default(0)->comment('家长ID');
$table->string('email', 200)->nullable()->comment('电子邮件');
$table->string('phone_number', 11)->nullable()->comment('手机码');
$table->string('title', 200)->default('')->comment('头衔');
$table->string('avatar', 200)->default('')->comment('头像URL');
$table->dateTime('reg_time')->nullable()->comment('注册时间');
$table->string('reg_ip', 20)->nullable()->comment('注册IP');
$table->unsignedInteger('status')->default(1)->comment('用户状态:0禁用1正常2欠费3未激活');
$table->unsignedInteger('vip_level')->default(0)->comment('常规VIP等级');
$table->unsignedTinyInteger('sex')->default(0)->comment('性别1是男2是女0是不填');
$table->string('qq', 20)->nullable()->comment('QQ号');
$table->string('examing_number', 50)->nullable()->comment('考号');
// 创建索引
$table->index('email');
$table->index('role');
$table->index('parent_id');
$table->index('status');
$table->index('vip_level');
$table->index('phone_number');
$table->index('grade_id');
$table->index('sex');
$table->index('real_name');
$table->index('examing_number');
$table->index(['role', 'status', 'id'], 'idx_user_role_status_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('student');
}
};