mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Handle delivery log partition identities
Co-authored-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
parent
82a8b6a945
commit
ebd11f6608
@@ -81,11 +81,19 @@ BEGIN
|
||||
FOR VALUES FROM ('2026-07-01') TO (MAXVALUE);
|
||||
END IF;
|
||||
|
||||
-- When pgschema creates partition children as standalone tables, it also
|
||||
-- preserves the parent's identity column on delivery_log children. PostgreSQL
|
||||
-- rejects attaching a child table that has its own identity column, so each
|
||||
-- delivery_log attach path drops that standalone identity first. Raw
|
||||
-- schema-created partitions are already attached, so these branches do not
|
||||
-- run against inherited partition columns.
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_inherits
|
||||
WHERE inhparent = 'delivery_log'::regclass
|
||||
AND inhrelid = 'delivery_log_p_past'::regclass
|
||||
) THEN
|
||||
ALTER TABLE delivery_log_p_past ALTER COLUMN id DROP IDENTITY IF EXISTS;
|
||||
ALTER TABLE delivery_log ATTACH PARTITION delivery_log_p_past
|
||||
FOR VALUES FROM (MINVALUE) TO ('2026-03-01');
|
||||
END IF;
|
||||
@@ -95,6 +103,7 @@ BEGIN
|
||||
WHERE inhparent = 'delivery_log'::regclass
|
||||
AND inhrelid = 'delivery_log_p2026_03'::regclass
|
||||
) THEN
|
||||
ALTER TABLE delivery_log_p2026_03 ALTER COLUMN id DROP IDENTITY IF EXISTS;
|
||||
ALTER TABLE delivery_log ATTACH PARTITION delivery_log_p2026_03
|
||||
FOR VALUES FROM ('2026-03-01') TO ('2026-04-01');
|
||||
END IF;
|
||||
@@ -104,6 +113,7 @@ BEGIN
|
||||
WHERE inhparent = 'delivery_log'::regclass
|
||||
AND inhrelid = 'delivery_log_p2026_04'::regclass
|
||||
) THEN
|
||||
ALTER TABLE delivery_log_p2026_04 ALTER COLUMN id DROP IDENTITY IF EXISTS;
|
||||
ALTER TABLE delivery_log ATTACH PARTITION delivery_log_p2026_04
|
||||
FOR VALUES FROM ('2026-04-01') TO ('2026-05-01');
|
||||
END IF;
|
||||
@@ -113,6 +123,7 @@ BEGIN
|
||||
WHERE inhparent = 'delivery_log'::regclass
|
||||
AND inhrelid = 'delivery_log_p2026_05'::regclass
|
||||
) THEN
|
||||
ALTER TABLE delivery_log_p2026_05 ALTER COLUMN id DROP IDENTITY IF EXISTS;
|
||||
ALTER TABLE delivery_log ATTACH PARTITION delivery_log_p2026_05
|
||||
FOR VALUES FROM ('2026-05-01') TO ('2026-06-01');
|
||||
END IF;
|
||||
@@ -122,6 +133,7 @@ BEGIN
|
||||
WHERE inhparent = 'delivery_log'::regclass
|
||||
AND inhrelid = 'delivery_log_p2026_06'::regclass
|
||||
) THEN
|
||||
ALTER TABLE delivery_log_p2026_06 ALTER COLUMN id DROP IDENTITY IF EXISTS;
|
||||
ALTER TABLE delivery_log ATTACH PARTITION delivery_log_p2026_06
|
||||
FOR VALUES FROM ('2026-06-01') TO ('2026-07-01');
|
||||
END IF;
|
||||
@@ -131,6 +143,7 @@ BEGIN
|
||||
WHERE inhparent = 'delivery_log'::regclass
|
||||
AND inhrelid = 'delivery_log_p_future'::regclass
|
||||
) THEN
|
||||
ALTER TABLE delivery_log_p_future ALTER COLUMN id DROP IDENTITY IF EXISTS;
|
||||
ALTER TABLE delivery_log ATTACH PARTITION delivery_log_p_future
|
||||
FOR VALUES FROM ('2026-07-01') TO (MAXVALUE);
|
||||
END IF;
|
||||
|
||||
Reference in New Issue
Block a user