hyperf-chat/migrations/2020_11_04_152602_create_us...

45 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2020-11-04 16:47:17 +08:00
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
2021-09-12 16:23:43 +08:00
$table->unsignedInteger('id', true)->autoIncrement()->comment('用户ID');
2021-08-01 19:57:41 +08:00
$table->string('mobile', 11)->default('')->comment('手机号');
2020-11-04 16:47:17 +08:00
$table->string('nickname', 20)->default('')->comment('用户昵称');
$table->string('avatar', 255)->default('')->comment('用户头像地址');
2021-07-08 19:09:06 +08:00
$table->unsignedTinyInteger('gender')->default(0)->comment('用户性别[0:未知;1:男;2:女;]');
2020-11-04 16:47:17 +08:00
$table->string('password', 255)->default('')->comment('用户密码');
$table->string('motto', 100)->default('')->comment('用户座右铭');
$table->string('email', 30)->default('')->comment('用户邮箱');
2021-07-08 19:09:06 +08:00
$table->unsignedTinyInteger('is_robot')->default(0)->comment('是否机器人[0:否;1:是;]');
2022-01-21 22:19:42 +08:00
$table->dateTime('created_at')->nullable()->comment('创建时间');
2021-07-05 21:52:44 +08:00
$table->dateTime('updated_at')->nullable()->comment('更新时间');
2020-11-04 16:47:17 +08:00
2021-07-05 21:52:44 +08:00
$table->charset = 'utf8';
2020-11-04 16:47:17 +08:00
$table->collation = 'utf8_general_ci';
2021-07-05 21:52:44 +08:00
$table->engine = 'InnoDB';
2020-11-04 16:47:17 +08:00
2021-08-01 19:57:41 +08:00
$table->unique(['mobile'], 'uk_mobile');
2020-11-04 16:47:17 +08:00
2021-08-27 23:50:40 +08:00
$table->comment('用户信息表');
});
2020-11-04 16:47:17 +08:00
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
}