hyperf-chat/migrations/2020_11_04_153251_create_ar...

44 lines
1.7 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 CreateArticleAnnexTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('article_annex', function (Blueprint $table) {
$table->unsignedBigInteger('id', true)->comment('文件ID');
$table->unsignedInteger('user_id')->unsigned()->comment('上传文件的用户ID');
$table->unsignedInteger('article_id')->default(0)->comment('笔记ID');
$table->string('file_suffix', 10)->default('')->comment('文件后缀名');
2021-07-08 19:09:06 +08:00
$table->unsignedBigInteger('file_size')->default(0)->comment('文件大小(单位字节)');
$table->string('save_dir', 500)->nullable(false)->default('')->comment('文件保存地址(相对地址)');
$table->string('original_name', 100)->nullable(false)->default('')->comment('原文件名');
$table->unsignedTinyInteger('status')->default(1)->comment('附件状态[1:正常;2:已删除]');
2020-11-04 16:47:17 +08:00
$table->dateTime('created_at')->nullable(true)->comment('附件上传时间');
$table->dateTime('deleted_at')->nullable(true)->comment('附件删除时间');
2021-07-08 19:09:06 +08:00
$table->charset = 'utf8';
2020-11-04 16:47:17 +08:00
$table->collation = 'utf8_general_ci';
2021-07-08 19:09:06 +08:00
$table->engine = 'InnoDB';
2020-11-04 16:47:17 +08:00
$table->index(['user_id', 'article_id'], 'idx_user_id_article_id');
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_annex');
}
}