hyperf-chat/migrations/2020_11_04_153304_create_ar...

40 lines
1.3 KiB
PHP
Raw 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;
2021-08-27 23:50:40 +08:00
2020-11-04 16:47:17 +08:00
class CreateArticleClassTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('article_class', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('笔记分类ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->string('class_name', 20)->default('')->comment('分类名');
$table->unsignedTinyInteger('sort')->default(0)->comment('排序');
$table->unsignedTinyInteger('is_default')->default(0)->comment('默认分类[1:是;0:不是]');
2022-01-21 22:19:42 +08:00
$table->dateTime('created_at')->nullable(true)->comment('创建时间');
$table->dateTime('updated_at')->nullable(true)->comment('更新时间');
2020-11-04 16:47:17 +08:00
2021-08-27 23:50:40 +08:00
$table->charset = 'utf8';
2020-11-04 16:47:17 +08:00
$table->collation = 'utf8_general_ci';
2021-08-27 23:50:40 +08:00
$table->engine = 'InnoDB';
2020-11-04 16:47:17 +08:00
$table->index(['user_id', 'sort'], 'idx_user_id_sort');
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('article_class');
}
}