From 769e0b59f059293572e8a812ebf4c5538f3142ed Mon Sep 17 00:00:00 2001 From: Lucas Rayan Date: Sat, 1 Aug 2026 22:42:43 -0300 Subject: [PATCH] #14: add DEFAULT fallback partition to email_messages table schema --- migrations/0001_init_schema.up.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migrations/0001_init_schema.up.sql b/migrations/0001_init_schema.up.sql index c651ad4..84db2c2 100644 --- a/migrations/0001_init_schema.up.sql +++ b/migrations/0001_init_schema.up.sql @@ -266,9 +266,12 @@ CREATE TABLE email_messages ( ) PARTITION BY RANGE (received_at); -- Partitions are created by a monthly job (pg_partman or a custom routine). --- Seed the current month so local dev / F0 has a writable partition out of the box. +-- Seed partitions and a DEFAULT fallback so dev/test runs never fail on month boundaries. CREATE TABLE email_messages_2026_07 PARTITION OF email_messages FOR VALUES FROM ('2026-07-01') TO ('2026-08-01'); +CREATE TABLE email_messages_2026_08 PARTITION OF email_messages + FOR VALUES FROM ('2026-08-01') TO ('2026-09-01'); +CREATE TABLE email_messages_default PARTITION OF email_messages DEFAULT; -- Uniqueness index (folder_id, uid): on a partitioned table, every UNIQUE index -- must include the partition key - so this alone does NOT guarantee the invariant