0033_storage_limits.sql27 lines · main
| 1 | -- 0033_storage_limits — Sprint 4 storage admin. |
| 2 | -- |
| 3 | -- DoltGres can't report byte sizes, so storage is governed by ROW + TABLE |
| 4 | -- counts. This migration makes the Free/Pro/Team caps DB-backed (so an admin |
| 5 | -- can edit them without a redeploy) and adds optional per-project overrides. |
| 6 | -- |
| 7 | -- DoltGres-safe by construction: only text/bigint/timestamptz columns, a plain |
| 8 | -- PRIMARY KEY, ON CONFLICT DO NOTHING (supported), and bare ADD COLUMN. No |
| 9 | -- partial/expression indexes, no DO $$ blocks, no pg_catalog functions. |
| 10 | |
| 11 | CREATE TABLE IF NOT EXISTS "tier_storage_caps" ( |
| 12 | "tier" text PRIMARY KEY NOT NULL, |
| 13 | "max_rows" bigint NOT NULL, |
| 14 | "max_tables" bigint NOT NULL, |
| 15 | "updated_at" timestamp with time zone DEFAULT now() NOT NULL, |
| 16 | "updated_by" text |
| 17 | ); |
| 18 | --> statement-breakpoint |
| 19 | INSERT INTO "tier_storage_caps" ("tier", "max_rows", "max_tables") VALUES |
| 20 | ('free', 100000, 50), |
| 21 | ('pro', 5000000, 500), |
| 22 | ('team', 50000000, 5000) |
| 23 | ON CONFLICT ("tier") DO NOTHING; |
| 24 | --> statement-breakpoint |
| 25 | ALTER TABLE "projects" ADD COLUMN "storage_max_rows" bigint; |
| 26 | --> statement-breakpoint |
| 27 | ALTER TABLE "projects" ADD COLUMN "storage_max_tables" bigint; |