godcrm/backend/database/migrations/028-adr-0060-flip-is-public-default.sql
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

39 lines
1.7 KiB
PL/PgSQL

-- Migration 028: ADR-0060 P4 — flip is_public semantics to opt-out
--
-- After the pivot (commit 8094af43), space-level `public_slug` is the only
-- visibility gate. Per-entity `is_public` flags become OPT-OUT hooks: a row
-- is visible by default; the owner explicitly hides it via project / module
-- settings UIs (mirrors the column-level `config.is_public === false` pattern).
--
-- Net change:
-- default FALSE → default TRUE
-- backfill existing rows from FALSE → TRUE so they keep their current
-- "visible inside a public space" behaviour established by the pivot.
--
-- Non-public spaces are unaffected: their entities are still gated by
-- `space.public_slug IS NULL` at the route layer, regardless of this flag.
--
-- Created: 2026-05-14
-- ADR: 0060 (doc 152799)
BEGIN;
ALTER TABLE projects ALTER COLUMN is_public SET DEFAULT TRUE;
ALTER TABLE universal_tables ALTER COLUMN is_public SET DEFAULT TRUE;
ALTER TABLE dashboards ALTER COLUMN is_public SET DEFAULT TRUE;
ALTER TABLE widgets ALTER COLUMN is_public SET DEFAULT TRUE;
UPDATE projects SET is_public = TRUE WHERE is_public = FALSE;
UPDATE universal_tables SET is_public = TRUE WHERE is_public = FALSE;
UPDATE dashboards SET is_public = TRUE WHERE is_public = FALSE;
UPDATE widgets SET is_public = TRUE WHERE is_public = FALSE;
COMMIT;
-- DOWN (manual / dev only):
-- BEGIN;
-- ALTER TABLE projects ALTER COLUMN is_public SET DEFAULT FALSE;
-- ALTER TABLE universal_tables ALTER COLUMN is_public SET DEFAULT FALSE;
-- ALTER TABLE dashboards ALTER COLUMN is_public SET DEFAULT FALSE;
-- ALTER TABLE widgets ALTER COLUMN is_public SET DEFAULT FALSE;
-- COMMIT;