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'); + }); + } +};