diff --git a/database/migrations/2025_07_24_131242_update_files_table_for_common_usage.php b/database/migrations/2025_07_24_131242_update_files_table_for_common_usage.php new file mode 100644 index 0000000..8769762 --- /dev/null +++ b/database/migrations/2025_07_24_131242_update_files_table_for_common_usage.php @@ -0,0 +1,37 @@ +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' + ]); + }); + } +};