From bc1379c95e2b191a834d1698e9964d779a6a9239 Mon Sep 17 00:00:00 2001 From: chazy-d Date: Thu, 6 Aug 2026 20:15:29 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20project=5Ffile=20=EB=A0=88=EA=B1=B0?= =?UTF-8?q?=EC=8B=9C=20=EC=BB=AC=EB=9F=BC=20=EC=A0=9C=EA=B1=B0=EB=A1=9C=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EB=B3=B5?= =?UTF-8?q?=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 파일 업로드가 운영에서 전건 500으로 실패했다. JpaSystemException: could not execute statement [Field 'file_url' doesn't have a default value] at ProjectFileService.uploadProjectFile(ProjectFileService.java:124) a833792 에서 ProjectFile 의 file_url 을 storage_key 로, isPinned(boolean) 을 pinnedAt(nullable) 로 바꾸면서 대응 마이그레이션을 만들지 않았다. 운영 DB 는 ddl-auto=update 로 생성돼 신규 컬럼만 추가되고 구 컬럼 file_url, is_pinned 가 NOT NULL / DEFAULT 없음 상태로 남았다. 현재 INSERT 문은 두 컬럼을 포함하지 않으므로 모든 INSERT 가 거부된다. ddl-auto=validate 는 엔티티에 있는데 DB 에 없는 컬럼만 검사하고 그 반대는 보지 않아 이 상태를 잡아내지 못했다. 운영 DB 전체 컬럼을 엔티티와 대조해 같은 유형의 고아 컬럼이 project_file 두 건뿐임을 확인했다. file_url 만 제거하면 다음 업로드에서 is_pinned 로 동일하게 실패하므로 함께 제거한다. 삭제 시점 기준 project_file 은 0건이라 데이터 손실이 없다. V011 은 d5191f6 에서 쓰였다가 f1e99f0 에서 삭제된 이력이 있어 재사용하지 않는다. --- ...V012__project_file_drop_legacy_columns.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/resources/db/migration/V012__project_file_drop_legacy_columns.sql diff --git a/src/main/resources/db/migration/V012__project_file_drop_legacy_columns.sql b/src/main/resources/db/migration/V012__project_file_drop_legacy_columns.sql new file mode 100644 index 0000000..935cca8 --- /dev/null +++ b/src/main/resources/db/migration/V012__project_file_drop_legacy_columns.sql @@ -0,0 +1,26 @@ +-- project_file 레거시 컬럼 제거 (file_url, is_pinned) +-- +-- 배경: +-- a833792(2026-07-23) "프로젝트 파일 도메인 모델 정리"에서 ProjectFile 엔티티의 +-- file_url -> storage_key, isPinned(boolean) -> pinnedAt(nullable) 으로 모델을 바꿨으나 +-- 대응 마이그레이션이 없었다. 운영 DB는 ddl-auto=update로 생성돼 신규 컬럼만 추가되고 +-- 구 컬럼 두 개가 NOT NULL / DEFAULT 없음 상태로 남았다. +-- 현재 INSERT문은 두 컬럼을 포함하지 않으므로 파일 업로드가 전건 실패한다. +-- Field 'file_url' doesn't have a default value +-- ddl-auto=validate는 "엔티티에 있는데 DB에 없는 컬럼"만 검사하고 그 반대는 보지 않아 +-- 이 상태를 잡아내지 못했다. +-- +-- 안전성: +-- 삭제 시점 기준 project_file 행 수 0건이므로 데이터 손실 없음. +-- +-- 주의: +-- MySQL 8.4에는 DROP COLUMN IF EXISTS가 없다(MariaDB 전용 문법). 조건 없이 삭제한다. +-- 따라서 두 컬럼이 존재하는 DB에서만 성공한다. 운영 DB에서 직접 DROP을 먼저 실행하면 +-- 이 마이그레이션이 ERROR 1091로 실패해 이후 배포가 모두 막히므로 절대 병행하지 말 것. +-- +-- 버전 번호: +-- V011은 d5191f6에서 activity_log 인덱스용으로 쓰였다가 f1e99f0에서 삭제된 이력이 있어 +-- 재사용하지 않는다. 번호를 비워도 Flyway 동작에는 영향이 없다. +ALTER TABLE project_file + DROP COLUMN file_url, + DROP COLUMN is_pinned;