hyperf-chat/migrations/2020_11_04_153358_create_sp...

46 lines
1.9 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
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:拆分文件]');
2020-11-04 16:47:17 +08:00
$table->unsignedInteger('user_id')->default(0)->comment('上传的用户ID');
2022-01-21 22:19:42 +08:00
$table->string('upload_id', 32)->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-21 22:19:42 +08:00
$table->unsignedInteger('created_at')->nullable(true)->comment('创建时间');
$table->unsignedInteger('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
}
}