File tree Expand file tree Collapse file tree
backend/src/main/resources/db/migration Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* =========================================================
2+ * 1. Drop FK: fk_v2_order_ticket (잘못된 참조 제거)
3+ * ========================================================= */
4+ DO $$
5+ BEGIN
6+ IF EXISTS (
7+ SELECT 1
8+ FROM pg_constraint
9+ WHERE conname = ' fk_v2_order_ticket'
10+ ) THEN
11+ ALTER TABLE v2_orders
12+ DROP CONSTRAINT fk_v2_order_ticket;
13+ END IF;
14+ END $$;
15+
16+
17+ /* =========================================================
18+ * 2. Foreign Key: v2_orders.ticket_id → tickets.id (올바른 참조)
19+ * ========================================================= */
20+ DO $$
21+ BEGIN
22+ IF NOT EXISTS (
23+ SELECT 1
24+ FROM pg_constraint
25+ WHERE conname = ' fk_v2_order_ticket'
26+ ) THEN
27+ ALTER TABLE v2_orders
28+ ADD CONSTRAINT fk_v2_order_ticket
29+ FOREIGN KEY (ticket_id)
30+ REFERENCES tickets(id);
31+ END IF;
32+ END $$;
You can’t perform that action at this time.
0 commit comments