0033_storage_limits.sql 1.1 KB

123456789101112131415161718192021222324252627
  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. CREATE TABLE IF NOT EXISTS "tier_storage_caps" (
  11. "tier" text PRIMARY KEY NOT NULL,
  12. "max_rows" bigint NOT NULL,
  13. "max_tables" bigint NOT NULL,
  14. "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
  15. "updated_by" text
  16. );
  17. --> statement-breakpoint
  18. INSERT INTO "tier_storage_caps" ("tier", "max_rows", "max_tables") VALUES
  19. ('free', 100000, 50),
  20. ('pro', 5000000, 500),
  21. ('team', 50000000, 5000)
  22. ON CONFLICT ("tier") DO NOTHING;
  23. --> statement-breakpoint
  24. ALTER TABLE "projects" ADD COLUMN "storage_max_rows" bigint;
  25. --> statement-breakpoint
  26. ALTER TABLE "projects" ADD COLUMN "storage_max_tables" bigint;