From 19839323ae51afaa8c8cdd1a6bccdebb842a7027 Mon Sep 17 00:00:00 2001 From: hskwon Date: Thu, 24 Jul 2025 18:08:24 +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-=20Polymorphic=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...date_files_table_for_polymorphic_usage.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 database/migrations/2025_07_24_180652_update_files_table_for_polymorphic_usage.php diff --git a/database/migrations/2025_07_24_180652_update_files_table_for_polymorphic_usage.php b/database/migrations/2025_07_24_180652_update_files_table_for_polymorphic_usage.php new file mode 100644 index 0000000..a3b582d --- /dev/null +++ b/database/migrations/2025_07_24_180652_update_files_table_for_polymorphic_usage.php @@ -0,0 +1,32 @@ +dropColumn(['target_table', 'target_id']); + + // Polymorphic 컬럼 추가 + $table->unsignedBigInteger('fileable_id')->after('description')->comment('Polymorphic - 연결된 모델의 PK'); + $table->string('fileable_type', 100)->after('fileable_id')->comment('Polymorphic - 연결된 모델 클래스명'); + }); + } + + public function down(): void + { + Schema::table('files', function (Blueprint $table) { + // Polymorphic 컬럼 제거 + $table->dropColumn(['fileable_id', 'fileable_type']); + + // 다시 기존 방식으로 복원 + $table->string('target_table', 50)->after('description')->comment('연결된 테이블명'); + $table->unsignedBigInteger('target_id')->after('target_table')->comment('연결된 테이블의 PK ID'); + }); + } +};