fix : 공통으로 파일관리 - file 테이블 공통 관리
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateFilesTableForCommonUsage extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('files', function (Blueprint $table) {
|
||||
// 기존 컬럼명 변경
|
||||
$table->renameColumn('file_name', 'file_name_old'); // 잠시 백업
|
||||
|
||||
// 새로운 컬럼 추가
|
||||
$table->string('original_name', 255)->after('file_path')->comment('원본 파일명');
|
||||
$table->string('file_name', 255)->after('original_name')->comment('저장 파일명 (난수)');
|
||||
$table->string('target_table', 50)->after('description')->comment('연결된 테이블명');
|
||||
$table->unsignedBigInteger('target_id')->after('target_table')->comment('연결된 테이블의 PK ID');
|
||||
$table->unsignedBigInteger('uploaded_by')->nullable()->after('target_id')->comment('업로더 사용자 ID');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('files', function (Blueprint $table) {
|
||||
// 복구 시 이전 file_name 복원
|
||||
$table->string('file_name', 255)->after('file_path');
|
||||
$table->dropColumn([
|
||||
'original_name',
|
||||
'target_table',
|
||||
'target_id',
|
||||
'uploaded_by'
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user