Files
threadcount-community/prisma/migrations/20260912070000_platform_switches/migration.sql
T
ThreadCount 1bc2de655a ThreadCount Community edition
Uniform stock management for healthcare linen rooms. Licensed under the GNU AGPL v3.
2026-09-13 08:45:19 +10:00

25 lines
992 B
SQL

-- Platform switches the console can flip without a deploy, and the billing scaffold.
CREATE TABLE "PlatformSwitch" (
"id" TEXT NOT NULL DEFAULT 'platform',
"signupsDisabled" BOOLEAN NOT NULL DEFAULT false,
"demoDisabled" BOOLEAN NOT NULL DEFAULT false,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "PlatformSwitch_pkey" PRIMARY KEY ("id")
);
ALTER TABLE "Facility" ADD COLUMN "plan" TEXT NOT NULL DEFAULT '',
ADD COLUMN "planNote" TEXT NOT NULL DEFAULT '';
-- The console may read the two new control-plane columns. Guarded like every ops grant: no role,
-- no grant, no failed deploy. (`prisma migrate deploy` runs as the app role, which owns the table,
-- so the grant itself needs no more than that.)
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'ops_ro') THEN
RAISE NOTICE 'ops_ro does not exist — plan grants skipped';
RETURN;
END IF;
GRANT SELECT ("plan", "planNote") ON "Facility" TO ops_ro;
END $$;