47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('files', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('user_id')->nullable()->constrained()->onDelete('set null');
|
|
$table->string('original_name')->comment('原始文件名');
|
|
$table->string('storage_name')->comment('存储文件名');
|
|
$table->string('path')->comment('存储路径');
|
|
$table->string('url')->nullable()->comment('文件URL');
|
|
$table->string('mime_type')->comment('文件类型');
|
|
$table->integer('size')->default(0)->comment('文件大小(字节)');
|
|
$table->string('extension')->comment('文件扩展名');
|
|
$table->string('disk')->default('public')->comment('存储磁盘');
|
|
$table->string('module')->default('default')->comment('所属模块');
|
|
$table->string('purpose')->default('upload')->comment('文件用途');
|
|
$table->text('description')->nullable()->comment('文件描述');
|
|
$table->enum('status', ['active', 'inactive', 'deleted'])->default('active')->comment('状态');
|
|
$table->timestamps();
|
|
|
|
$table->index('user_id');
|
|
$table->index('module');
|
|
$table->index('purpose');
|
|
$table->index('mime_type');
|
|
$table->index('status');
|
|
$table->index('created_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('files');
|
|
}
|
|
}; |