3abccc512d
CREATE TABLE + CREATE INDEX 한 파일에 들어가 asyncpg prepared statement 원칙 위반 (cannot insert multiple commands). 198 = TABLE 만, 199 = idx 분리. 첫 시작에서 198 적용 fail 로 init_db 트랜잭션 전체 롤백 → 컨테이너 시작 후 schema_migrations 미반영 + study_question_images 테이블 미생성. 본 fix 후 다음 시작 시 198+199 순차 적용.
19 lines
948 B
SQL
19 lines
948 B
SQL
-- 198_study_question_images.sql (1/2)
|
|
-- 문제별 첨부 이미지 (PR-8). 한 문제에 여러 이미지 가능 (회로도+그래프 등).
|
|
--
|
|
-- 저장 위치: NAS `/documents/study_question_images/{topic_id}/{question_id}/{image_id}.{ext}`
|
|
-- (file_watcher 가 보는 PKM 경로와 분리 — 자동 인덱싱 안 됨).
|
|
--
|
|
-- soft delete 미사용 (이미지는 hard delete + 파일 시스템 정리). 충분히 작은 자원.
|
|
|
|
CREATE TABLE IF NOT EXISTS study_question_images (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
study_question_id BIGINT NOT NULL REFERENCES study_questions(id) ON DELETE CASCADE,
|
|
file_path TEXT NOT NULL,
|
|
file_size BIGINT NOT NULL,
|
|
mime_type VARCHAR(80) NOT NULL,
|
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|