From d01fda52904842b59ad73427f51698b4b770d7bd Mon Sep 17 00:00:00 2001 From: hskwon Date: Thu, 24 Jul 2025 13:23:27 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EA=B3=B5=ED=86=B5=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=EA=B4=80=EB=A6=AC=20-=20file=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94=20=EA=B3=B5=ED=86=B5=20=EA=B4=80=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...42_update_files_table_for_common_usage.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 database/migrations/2025_07_24_131242_update_files_table_for_common_usage.php 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' + ]); + }); + } +};