hyperf-chat/migrations/2020_11_04_153238_create_ar...

47 lines
1.8 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;
class CreateArticleTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('article', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('笔记ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->unsignedInteger('class_id')->default(0)->comment('分类ID');
2021-08-10 21:21:26 +08:00
$table->string('tags_id', 100)->default('')->comment('笔记关联标签');
2020-11-04 16:47:17 +08:00
$table->string('title', 80)->default('')->charset('utf8mb4')->comment('笔记标题');
$table->string('abstract', 200)->default('')->charset('utf8mb4')->comment('笔记摘要');
$table->string('image', 255)->default('')->comment('笔记首图');
$table->unsignedTinyInteger('is_asterisk')->default(0)->comment('是否星标笔记[0:否;1:是]');
$table->unsignedTinyInteger('status')->default(1)->comment('笔记状态[1:正常;2:已删除]');
$table->dateTime('created_at')->nullable(true)->comment('添加时间');
$table->dateTime('updated_at')->nullable(true)->comment('最后一次更新时间');
$table->dateTime('deleted_at')->nullable(true)->comment('笔记删除时间');
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', 'class_id', 'title'], 'idx_user_id_class_id_title');
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');
}
}