hyperf-chat/migrations/2020_11_04_153358_create_sp...

48 lines
2.0 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;
2021-08-27 23:50:40 +08:00
2022-01-21 22:19:42 +08:00
class CreateSplitUploadTable extends Migration
2020-11-04 16:47:17 +08:00
{
/**
* Run the migrations.
*/
public function up(): void
{
2022-01-21 22:19:42 +08:00
Schema::create('split_upload', function (Blueprint $table) {
2020-11-04 16:47:17 +08:00
$table->unsignedInteger('id', true)->comment('临时文件ID');
2022-01-21 22:19:42 +08:00
$table->unsignedTinyInteger('type')->default(2)->comment('数据类型[1:合并文件;2:拆分文件]');
2022-01-23 15:13:58 +08:00
$table->unsignedInteger('drive')->unsigned()->default(1)->comment('文件驱动[1:local;2:cos;]');
2020-11-04 16:47:17 +08:00
$table->unsignedInteger('user_id')->default(0)->comment('上传的用户ID');
2022-05-05 21:04:07 +08:00
$table->string('upload_id', 100)->default('')->comment('上传文件ID');
2020-11-04 16:47:17 +08:00
$table->string('original_name', 100)->default('')->comment('原文件名');
$table->unsignedTinyInteger('split_index')->default(0)->comment('当前索引块');
$table->unsignedTinyInteger('split_num')->default(0)->comment('总上传索引块');
2022-01-21 22:19:42 +08:00
$table->string('path', 255)->default('')->comment('保存路径');
2020-11-04 16:47:17 +08:00
$table->string('file_ext', 10)->default('')->comment('文件后缀名');
$table->unsignedInteger('file_size')->default(0)->comment('临时文件大小');
$table->unsignedTinyInteger('is_delete')->default(0)->comment('文件是否已被删除[0:否;1:是]');
2022-01-23 15:13:58 +08:00
$table->json('attr')->nullable(false)->comment('额外参数Json');
$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';
2022-01-21 22:19:42 +08:00
$table->index(['user_id', 'upload_id'], 'idx_user_id_upload_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
{
2022-01-21 22:19:42 +08:00
Schema::dropIfExists('split_upload');
2020-11-04 16:47:17 +08:00
}
}