Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

P1.6: keep shipped migration text byte-identical; only the schema.sql base RLS block is conditional (fragment edits reverted, migrations golden back to master's records)

garrytanb81e6905c801
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ffbee5ac7..23d99716f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,7 +38,7 @@ Eleven reports from large brains, managed checkouts and the schema tooling. Each
- **Export output gains a line.** A page whose slug the path cannot derive is exported with `slug:` in its frontmatter; byte-for-byte comparisons of such exports change once.
- **A live-destination rename is not held.** Holding it would break the pinned fallback-reconcile contract (#3056, #3479, #3583); the fallback keeps running and now carries the page's identity. The hold design is parked, not shipped.
- **`init` and `upgrade` can now fail where they used to wait.** A blocked step exits with `schema_lock_blocked` after the bound; rerun after the named session ends. Set `GBRAIN_SCHEMA_LOCK_TIMEOUT_SECONDS` higher for a maintenance window where waiting is wanted.
-- **Ten shipped migrations' SQL text changed** (v184–v187, v204, v212, v213, v227 and the shared-skills and purge fragments): they share the schema fragments whose `ENABLE ROW LEVEL SECURITY` became conditional. A brain already past them never re-runs them; a brain behind them runs the equivalent conditional form. The migrations golden was regenerated for exactly these ten records.
+- **Shipped migration text is unchanged.** Only the `src/schema.sql` base RLS block became conditional; the TS schema fragments that double as migration text (`v184`–`v187`, `v204`, `v212`, `v213`, `v227`, the shared-skills and purge fragments) keep their bytes, so their replays at init still take ACCESS EXCLUSIVE on their tables, now under the bounded `lock_timeout` with the blocker named.
- **Not fixed here:** the `transaction: false` handler migrations and the post-migration `verifySchema` run outside the lock bound (they issue their own statements); the recorded flake in the v24 RLS test stays open while that test now calls the migration handler directly.
### Itemized changes
diff --git a/src/core/ai/decide/schema.ts b/src/core/ai/decide/schema.ts
index 0131351b1c..0e2e39b16a 100644
--- a/src/core/ai/decide/schema.ts
+++ b/src/core/ai/decide/schema.ts
@@ -9,7 +9,7 @@
const rls = (table: string) => `DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = '${table}' AND c.relrowsecurity) THEN ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;`;
diff --git a/src/core/core-memory-schema.ts b/src/core/core-memory-schema.ts
index d8f24e6dcd..f41a2c6056 100644
--- a/src/core/core-memory-schema.ts
+++ b/src/core/core-memory-schema.ts
@@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS core_edit_notices (
CREATE INDEX IF NOT EXISTS core_edit_notices_pending_idx ON core_edit_notices (source_id, slug, id) WHERE acked_at IS NULL;
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'core_edit_notices' AND c.relrowsecurity) THEN ALTER TABLE core_edit_notices ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE core_edit_notices ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
`;
diff --git a/src/core/eligibility/generation-schema.ts b/src/core/eligibility/generation-schema.ts
index 16de7ed1cb..16f8d31a0e 100644
--- a/src/core/eligibility/generation-schema.ts
+++ b/src/core/eligibility/generation-schema.ts
@@ -94,7 +94,7 @@ export const TRUST_GENERATION_SCHEMA_STATEMENTS: readonly string[] = [
)`,
`DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = '${TRUST_POLICY_STATE_TABLE}' AND c.relrowsecurity) THEN ALTER TABLE ${TRUST_POLICY_STATE_TABLE} ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE ${TRUST_POLICY_STATE_TABLE} ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$`,
`INSERT INTO ${TRUST_POLICY_STATE_TABLE} (id) VALUES (1) ON CONFLICT (id) DO NOTHING`,
diff --git a/src/core/facts/purge-schema.ts b/src/core/facts/purge-schema.ts
index 993168e36b..d185cd6961 100644
--- a/src/core/facts/purge-schema.ts
+++ b/src/core/facts/purge-schema.ts
@@ -26,7 +26,7 @@
const RLS = (table: string) => `DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = '${table}' AND c.relrowsecurity) THEN ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;`;
diff --git a/src/core/facts/relink-schema.ts b/src/core/facts/relink-schema.ts
index 704fc186bb..adfb4c2384 100644
--- a/src/core/facts/relink-schema.ts
+++ b/src/core/facts/relink-schema.ts
@@ -12,7 +12,7 @@
const rls = (table: string) => `DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = '${table}' AND c.relrowsecurity) THEN ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;`;
diff --git a/src/core/link-temporal-schema.ts b/src/core/link-temporal-schema.ts
index ebfdea5ac0..320172d6d1 100644
--- a/src/core/link-temporal-schema.ts
+++ b/src/core/link-temporal-schema.ts
@@ -19,7 +19,7 @@
const rls = (table: string) => `DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = '${table}' AND c.relrowsecurity) THEN ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;`;
diff --git a/src/core/pglite-schema.generated.ts b/src/core/pglite-schema.generated.ts
index 3cc7407450..e0e76a11e7 100644
--- a/src/core/pglite-schema.generated.ts
+++ b/src/core/pglite-schema.generated.ts
@@ -1774,10 +1774,7 @@ BEGIN
FOREACH target IN ARRAY ARRAY['shared_skill_state','shared_skill_policies','shared_skill_packs',
'shared_skill_policy_audit','shared_skill_heads','shared_skill_revisions','shared_skill_revision_leases',
'shared_skill_members','shared_skill_delivery_batches','persistence_writer_protocols'] LOOP
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
- WHERE n.nspname = current_schema() AND c.relname = target AND c.relrowsecurity) THEN
- EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY',target);
- END IF;
+ EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY',target);
END LOOP;
END IF;
END \$\$;
@@ -1840,17 +1837,17 @@ CREATE TABLE IF NOT EXISTS decide_state (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decision_receipts' AND c.relrowsecurity) THEN ALTER TABLE decision_receipts ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decision_receipts ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_spend' AND c.relrowsecurity) THEN ALTER TABLE decide_spend ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_spend ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_state' AND c.relrowsecurity) THEN ALTER TABLE decide_state ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_state ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -1884,7 +1881,7 @@ CREATE TABLE IF NOT EXISTS decide_calibrations (
CREATE INDEX IF NOT EXISTS decide_calibrations_lookup_idx ON decide_calibrations (slot, provider, model_resolved, created_at DESC);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_calibrations' AND c.relrowsecurity) THEN ALTER TABLE decide_calibrations ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_calibrations ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -1920,12 +1917,12 @@ CREATE TABLE IF NOT EXISTS decide_sweep_deferred (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_proposals' AND c.relrowsecurity) THEN ALTER TABLE decide_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_sweep_deferred' AND c.relrowsecurity) THEN ALTER TABLE decide_sweep_deferred ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_sweep_deferred ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -1963,12 +1960,12 @@ CREATE TABLE IF NOT EXISTS decide_review_proposals (
CREATE INDEX IF NOT EXISTS decide_review_proposals_status_idx ON decide_review_proposals (status, created_at);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_review_queue' AND c.relrowsecurity) THEN ALTER TABLE decide_review_queue ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_review_queue ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_review_proposals' AND c.relrowsecurity) THEN ALTER TABLE decide_review_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_review_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -1988,7 +1985,7 @@ CREATE TABLE IF NOT EXISTS fact_relink_attempts (
CREATE INDEX IF NOT EXISTS fact_relink_attempts_outcome_idx ON fact_relink_attempts (source_id, outcome, attempted_at);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'fact_relink_attempts' AND c.relrowsecurity) THEN ALTER TABLE fact_relink_attempts ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE fact_relink_attempts ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -2013,7 +2010,7 @@ CREATE INDEX IF NOT EXISTS link_transitions_relationship_idx ON link_transitions
CREATE INDEX IF NOT EXISTS link_transitions_origin_idx ON link_transitions (origin_page_id);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_transitions' AND c.relrowsecurity) THEN ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS link_relationships (
@@ -2041,7 +2038,7 @@ CREATE INDEX IF NOT EXISTS link_relationships_to_idx ON link_relationships (to_p
CREATE INDEX IF NOT EXISTS link_relationships_source_idx ON link_relationships (source_id, status_now);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_relationships' AND c.relrowsecurity) THEN ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS link_edge_proposals (
@@ -2068,7 +2065,7 @@ CREATE TABLE IF NOT EXISTS link_edge_proposals (
CREATE INDEX IF NOT EXISTS link_edge_proposals_status_idx ON link_edge_proposals (source_id, status, created_at);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_edge_proposals' AND c.relrowsecurity) THEN ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE SEQUENCE IF NOT EXISTS graph_generation_seq;
@@ -2089,7 +2086,7 @@ CREATE TABLE IF NOT EXISTS core_edit_notices (
CREATE INDEX IF NOT EXISTS core_edit_notices_pending_idx ON core_edit_notices (source_id, slug, id) WHERE acked_at IS NULL;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'core_edit_notices' AND c.relrowsecurity) THEN ALTER TABLE core_edit_notices ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE core_edit_notices ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -2107,7 +2104,7 @@ CREATE TABLE IF NOT EXISTS fact_purges (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'fact_purges' AND c.relrowsecurity) THEN ALTER TABLE fact_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE fact_purges ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS take_purges (
@@ -2120,7 +2117,7 @@ CREATE TABLE IF NOT EXISTS take_purges (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'take_purges' AND c.relrowsecurity) THEN ALTER TABLE take_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE take_purges ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS page_purges (
@@ -2133,7 +2130,7 @@ CREATE TABLE IF NOT EXISTS page_purges (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'page_purges' AND c.relrowsecurity) THEN ALTER TABLE page_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE page_purges ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS derivation_inputs (
@@ -2148,7 +2145,7 @@ CREATE TABLE IF NOT EXISTS derivation_inputs (
CREATE INDEX IF NOT EXISTS idx_derivation_inputs_input ON derivation_inputs (input_table, input_id);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'derivation_inputs' AND c.relrowsecurity) THEN ALTER TABLE derivation_inputs ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE derivation_inputs ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS needs_rederive (
@@ -2162,7 +2159,7 @@ CREATE TABLE IF NOT EXISTS needs_rederive (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'needs_rederive' AND c.relrowsecurity) THEN ALTER TABLE needs_rederive ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE needs_rederive ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -2213,8 +2210,8 @@ CREATE UNIQUE INDEX IF NOT EXISTS write_gate_holds_dedupe_idx ON write_gate_hold
CREATE INDEX IF NOT EXISTS write_gate_holds_status_idx ON write_gate_holds (status, source_id, id);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'write_gate_receipts' AND c.relrowsecurity) THEN ALTER TABLE write_gate_receipts ENABLE ROW LEVEL SECURITY; END IF;
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'write_gate_holds' AND c.relrowsecurity) THEN ALTER TABLE write_gate_holds ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE write_gate_receipts ENABLE ROW LEVEL SECURITY;
+ ALTER TABLE write_gate_holds ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
diff --git a/src/core/schema-embedded.generated.ts b/src/core/schema-embedded.generated.ts
index 0358f529c6..a289b94c4d 100644
--- a/src/core/schema-embedded.generated.ts
+++ b/src/core/schema-embedded.generated.ts
@@ -2490,10 +2490,7 @@ BEGIN
FOREACH target IN ARRAY ARRAY['shared_skill_state','shared_skill_policies','shared_skill_packs',
'shared_skill_policy_audit','shared_skill_heads','shared_skill_revisions','shared_skill_revision_leases',
'shared_skill_members','shared_skill_delivery_batches','persistence_writer_protocols'] LOOP
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
- WHERE n.nspname = current_schema() AND c.relname = target AND c.relrowsecurity) THEN
- EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY',target);
- END IF;
+ EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY',target);
END LOOP;
END IF;
END \$\$;
@@ -2558,17 +2555,17 @@ CREATE TABLE IF NOT EXISTS decide_state (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decision_receipts' AND c.relrowsecurity) THEN ALTER TABLE decision_receipts ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decision_receipts ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_spend' AND c.relrowsecurity) THEN ALTER TABLE decide_spend ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_spend ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_state' AND c.relrowsecurity) THEN ALTER TABLE decide_state ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_state ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -2602,7 +2599,7 @@ CREATE TABLE IF NOT EXISTS decide_calibrations (
CREATE INDEX IF NOT EXISTS decide_calibrations_lookup_idx ON decide_calibrations (slot, provider, model_resolved, created_at DESC);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_calibrations' AND c.relrowsecurity) THEN ALTER TABLE decide_calibrations ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_calibrations ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -2638,12 +2635,12 @@ CREATE TABLE IF NOT EXISTS decide_sweep_deferred (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_proposals' AND c.relrowsecurity) THEN ALTER TABLE decide_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_sweep_deferred' AND c.relrowsecurity) THEN ALTER TABLE decide_sweep_deferred ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_sweep_deferred ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
@@ -2681,12 +2678,12 @@ CREATE TABLE IF NOT EXISTS decide_review_proposals (
CREATE INDEX IF NOT EXISTS decide_review_proposals_status_idx ON decide_review_proposals (status, created_at);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_review_queue' AND c.relrowsecurity) THEN ALTER TABLE decide_review_queue ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_review_queue ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_review_proposals' AND c.relrowsecurity) THEN ALTER TABLE decide_review_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_review_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
-- END GENERATED from src/core/ai/decide/schema.ts (DECIDE_SCHEMA_SQL)
@@ -2708,7 +2705,7 @@ CREATE TABLE IF NOT EXISTS fact_relink_attempts (
CREATE INDEX IF NOT EXISTS fact_relink_attempts_outcome_idx ON fact_relink_attempts (source_id, outcome, attempted_at);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'fact_relink_attempts' AND c.relrowsecurity) THEN ALTER TABLE fact_relink_attempts ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE fact_relink_attempts ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
-- END GENERATED from src/core/facts/relink-schema.ts (FACT_RELINK_SCHEMA_SQL)
@@ -2735,7 +2732,7 @@ CREATE INDEX IF NOT EXISTS link_transitions_relationship_idx ON link_transitions
CREATE INDEX IF NOT EXISTS link_transitions_origin_idx ON link_transitions (origin_page_id);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_transitions' AND c.relrowsecurity) THEN ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS link_relationships (
@@ -2763,7 +2760,7 @@ CREATE INDEX IF NOT EXISTS link_relationships_to_idx ON link_relationships (to_p
CREATE INDEX IF NOT EXISTS link_relationships_source_idx ON link_relationships (source_id, status_now);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_relationships' AND c.relrowsecurity) THEN ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS link_edge_proposals (
@@ -2790,7 +2787,7 @@ CREATE TABLE IF NOT EXISTS link_edge_proposals (
CREATE INDEX IF NOT EXISTS link_edge_proposals_status_idx ON link_edge_proposals (source_id, status, created_at);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_edge_proposals' AND c.relrowsecurity) THEN ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE SEQUENCE IF NOT EXISTS graph_generation_seq;
@@ -2813,7 +2810,7 @@ CREATE TABLE IF NOT EXISTS core_edit_notices (
CREATE INDEX IF NOT EXISTS core_edit_notices_pending_idx ON core_edit_notices (source_id, slug, id) WHERE acked_at IS NULL;
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'core_edit_notices' AND c.relrowsecurity) THEN ALTER TABLE core_edit_notices ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE core_edit_notices ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
-- END GENERATED from src/core/core-memory-schema.ts (CORE_EDIT_NOTICES_SCHEMA_SQL)
@@ -2833,7 +2830,7 @@ CREATE TABLE IF NOT EXISTS fact_purges (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'fact_purges' AND c.relrowsecurity) THEN ALTER TABLE fact_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE fact_purges ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS take_purges (
@@ -2846,7 +2843,7 @@ CREATE TABLE IF NOT EXISTS take_purges (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'take_purges' AND c.relrowsecurity) THEN ALTER TABLE take_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE take_purges ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS page_purges (
@@ -2859,7 +2856,7 @@ CREATE TABLE IF NOT EXISTS page_purges (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'page_purges' AND c.relrowsecurity) THEN ALTER TABLE page_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE page_purges ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS derivation_inputs (
@@ -2874,7 +2871,7 @@ CREATE TABLE IF NOT EXISTS derivation_inputs (
CREATE INDEX IF NOT EXISTS idx_derivation_inputs_input ON derivation_inputs (input_table, input_id);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'derivation_inputs' AND c.relrowsecurity) THEN ALTER TABLE derivation_inputs ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE derivation_inputs ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
CREATE TABLE IF NOT EXISTS needs_rederive (
@@ -2888,7 +2885,7 @@ CREATE TABLE IF NOT EXISTS needs_rederive (
);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'needs_rederive' AND c.relrowsecurity) THEN ALTER TABLE needs_rederive ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE needs_rederive ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
-- END GENERATED from src/core/facts/purge-schema.ts (MEMORY_PURGE_SCHEMA_SQL)
@@ -2943,8 +2940,8 @@ CREATE UNIQUE INDEX IF NOT EXISTS write_gate_holds_dedupe_idx ON write_gate_hold
CREATE INDEX IF NOT EXISTS write_gate_holds_status_idx ON write_gate_holds (status, source_id, id);
DO \$rls\$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'write_gate_receipts' AND c.relrowsecurity) THEN ALTER TABLE write_gate_receipts ENABLE ROW LEVEL SECURITY; END IF;
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'write_gate_holds' AND c.relrowsecurity) THEN ALTER TABLE write_gate_holds ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE write_gate_receipts ENABLE ROW LEVEL SECURITY;
+ ALTER TABLE write_gate_holds ENABLE ROW LEVEL SECURITY;
END IF;
END \$rls\$;
-- END GENERATED from src/core/write-gate-schema.ts (WRITE_GATE_SCHEMA_SQL)
diff --git a/src/core/shared-skills/access-schema.ts b/src/core/shared-skills/access-schema.ts
index da20ea6e78..e7eadcf611 100644
--- a/src/core/shared-skills/access-schema.ts
+++ b/src/core/shared-skills/access-schema.ts
@@ -7,10 +7,7 @@ BEGIN
FOREACH target IN ARRAY ARRAY['shared_skill_state','shared_skill_policies','shared_skill_packs',
'shared_skill_policy_audit','shared_skill_heads','shared_skill_revisions','shared_skill_revision_leases',
'shared_skill_members','shared_skill_delivery_batches','persistence_writer_protocols'] LOOP
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
- WHERE n.nspname = current_schema() AND c.relname = target AND c.relrowsecurity) THEN
- EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY',target);
- END IF;
+ EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY',target);
END LOOP;
END IF;
END $$;`;
diff --git a/src/core/write-gate-schema.ts b/src/core/write-gate-schema.ts
index 7fe329ab47..9261da9161 100644
--- a/src/core/write-gate-schema.ts
+++ b/src/core/write-gate-schema.ts
@@ -71,8 +71,8 @@ CREATE UNIQUE INDEX IF NOT EXISTS write_gate_holds_dedupe_idx ON write_gate_hold
CREATE INDEX IF NOT EXISTS write_gate_holds_status_idx ON write_gate_holds (status, source_id, id);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'write_gate_receipts' AND c.relrowsecurity) THEN ALTER TABLE write_gate_receipts ENABLE ROW LEVEL SECURITY; END IF;
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'write_gate_holds' AND c.relrowsecurity) THEN ALTER TABLE write_gate_holds ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE write_gate_receipts ENABLE ROW LEVEL SECURITY;
+ ALTER TABLE write_gate_holds ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
`;
diff --git a/src/schema.sql b/src/schema.sql
index 9e4b6332f9..cf26779451 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -2486,10 +2486,7 @@ BEGIN
FOREACH target IN ARRAY ARRAY['shared_skill_state','shared_skill_policies','shared_skill_packs',
'shared_skill_policy_audit','shared_skill_heads','shared_skill_revisions','shared_skill_revision_leases',
'shared_skill_members','shared_skill_delivery_batches','persistence_writer_protocols'] LOOP
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
- WHERE n.nspname = current_schema() AND c.relname = target AND c.relrowsecurity) THEN
- EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY',target);
- END IF;
+ EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY',target);
END LOOP;
END IF;
END $$;
@@ -2554,17 +2551,17 @@ CREATE TABLE IF NOT EXISTS decide_state (
);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decision_receipts' AND c.relrowsecurity) THEN ALTER TABLE decision_receipts ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decision_receipts ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_spend' AND c.relrowsecurity) THEN ALTER TABLE decide_spend ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_spend ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_state' AND c.relrowsecurity) THEN ALTER TABLE decide_state ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_state ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
@@ -2598,7 +2595,7 @@ CREATE TABLE IF NOT EXISTS decide_calibrations (
CREATE INDEX IF NOT EXISTS decide_calibrations_lookup_idx ON decide_calibrations (slot, provider, model_resolved, created_at DESC);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_calibrations' AND c.relrowsecurity) THEN ALTER TABLE decide_calibrations ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_calibrations ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
@@ -2634,12 +2631,12 @@ CREATE TABLE IF NOT EXISTS decide_sweep_deferred (
);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_proposals' AND c.relrowsecurity) THEN ALTER TABLE decide_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_sweep_deferred' AND c.relrowsecurity) THEN ALTER TABLE decide_sweep_deferred ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_sweep_deferred ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
@@ -2677,12 +2674,12 @@ CREATE TABLE IF NOT EXISTS decide_review_proposals (
CREATE INDEX IF NOT EXISTS decide_review_proposals_status_idx ON decide_review_proposals (status, created_at);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_review_queue' AND c.relrowsecurity) THEN ALTER TABLE decide_review_queue ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_review_queue ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'decide_review_proposals' AND c.relrowsecurity) THEN ALTER TABLE decide_review_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE decide_review_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
-- END GENERATED from src/core/ai/decide/schema.ts (DECIDE_SCHEMA_SQL)
@@ -2704,7 +2701,7 @@ CREATE TABLE IF NOT EXISTS fact_relink_attempts (
CREATE INDEX IF NOT EXISTS fact_relink_attempts_outcome_idx ON fact_relink_attempts (source_id, outcome, attempted_at);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'fact_relink_attempts' AND c.relrowsecurity) THEN ALTER TABLE fact_relink_attempts ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE fact_relink_attempts ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
-- END GENERATED from src/core/facts/relink-schema.ts (FACT_RELINK_SCHEMA_SQL)
@@ -2731,7 +2728,7 @@ CREATE INDEX IF NOT EXISTS link_transitions_relationship_idx ON link_transitions
CREATE INDEX IF NOT EXISTS link_transitions_origin_idx ON link_transitions (origin_page_id);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_transitions' AND c.relrowsecurity) THEN ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
CREATE TABLE IF NOT EXISTS link_relationships (
@@ -2759,7 +2756,7 @@ CREATE INDEX IF NOT EXISTS link_relationships_to_idx ON link_relationships (to_p
CREATE INDEX IF NOT EXISTS link_relationships_source_idx ON link_relationships (source_id, status_now);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_relationships' AND c.relrowsecurity) THEN ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
CREATE TABLE IF NOT EXISTS link_edge_proposals (
@@ -2786,7 +2783,7 @@ CREATE TABLE IF NOT EXISTS link_edge_proposals (
CREATE INDEX IF NOT EXISTS link_edge_proposals_status_idx ON link_edge_proposals (source_id, status, created_at);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'link_edge_proposals' AND c.relrowsecurity) THEN ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
CREATE SEQUENCE IF NOT EXISTS graph_generation_seq;
@@ -2809,7 +2806,7 @@ CREATE TABLE IF NOT EXISTS core_edit_notices (
CREATE INDEX IF NOT EXISTS core_edit_notices_pending_idx ON core_edit_notices (source_id, slug, id) WHERE acked_at IS NULL;
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'core_edit_notices' AND c.relrowsecurity) THEN ALTER TABLE core_edit_notices ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE core_edit_notices ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
-- END GENERATED from src/core/core-memory-schema.ts (CORE_EDIT_NOTICES_SCHEMA_SQL)
@@ -2829,7 +2826,7 @@ CREATE TABLE IF NOT EXISTS fact_purges (
);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'fact_purges' AND c.relrowsecurity) THEN ALTER TABLE fact_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE fact_purges ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
CREATE TABLE IF NOT EXISTS take_purges (
@@ -2842,7 +2839,7 @@ CREATE TABLE IF NOT EXISTS take_purges (
);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'take_purges' AND c.relrowsecurity) THEN ALTER TABLE take_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE take_purges ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
CREATE TABLE IF NOT EXISTS page_purges (
@@ -2855,7 +2852,7 @@ CREATE TABLE IF NOT EXISTS page_purges (
);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'page_purges' AND c.relrowsecurity) THEN ALTER TABLE page_purges ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE page_purges ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
CREATE TABLE IF NOT EXISTS derivation_inputs (
@@ -2870,7 +2867,7 @@ CREATE TABLE IF NOT EXISTS derivation_inputs (
CREATE INDEX IF NOT EXISTS idx_derivation_inputs_input ON derivation_inputs (input_table, input_id);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'derivation_inputs' AND c.relrowsecurity) THEN ALTER TABLE derivation_inputs ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE derivation_inputs ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
CREATE TABLE IF NOT EXISTS needs_rederive (
@@ -2884,7 +2881,7 @@ CREATE TABLE IF NOT EXISTS needs_rederive (
);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'needs_rederive' AND c.relrowsecurity) THEN ALTER TABLE needs_rederive ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE needs_rederive ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
-- END GENERATED from src/core/facts/purge-schema.ts (MEMORY_PURGE_SCHEMA_SQL)
@@ -2939,8 +2936,8 @@ CREATE UNIQUE INDEX IF NOT EXISTS write_gate_holds_dedupe_idx ON write_gate_hold
CREATE INDEX IF NOT EXISTS write_gate_holds_status_idx ON write_gate_holds (status, source_id, id);
DO $rls$ BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'write_gate_receipts' AND c.relrowsecurity) THEN ALTER TABLE write_gate_receipts ENABLE ROW LEVEL SECURITY; END IF;
- IF NOT EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = current_schema() AND c.relname = 'write_gate_holds' AND c.relrowsecurity) THEN ALTER TABLE write_gate_holds ENABLE ROW LEVEL SECURITY; END IF;
+ ALTER TABLE write_gate_receipts ENABLE ROW LEVEL SECURITY;
+ ALTER TABLE write_gate_holds ENABLE ROW LEVEL SECURITY;
END IF;
END $rls$;
-- END GENERATED from src/core/write-gate-schema.ts (WRITE_GATE_SCHEMA_SQL)
diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.json
index 3e175e5e41..b29dec1fcf 100644
--- a/test/fixtures/goldens/migrations/records.json
+++ b/test/fixtures/goldens/migrations/records.json
@@ -2422,8 +2422,8 @@
"idempotent": true,
"name": "shared_brain_skills_and_membership",
"sql": {
- "length": 16131,
- "sha256": "ab561a58dbd312efb2210d1220d016436b6b7f6e657c4cd3c6178cb6d1241d08"
+ "length": 15917,
+ "sha256": "6d54ba001944603fd35abe6d6f355f106322a4e0dda206cfd93622fc1493e4aa"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -2734,8 +2734,8 @@
"idempotent": true,
"name": "decision_receipts",
"sql": {
- "length": 3282,
- "sha256": "1756ab10d9990a9e5e4e97a7d6f4b2e4d4fcd1afae0012693daac26d5687fcb2"
+ "length": 2716,
+ "sha256": "52fbd2953179f3124604362c4c2cd200349d5e45a14bc5866a41fafe537fd9bb"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -2747,8 +2747,8 @@
"idempotent": true,
"name": "decide_calibrations",
"sql": {
- "length": 1468,
- "sha256": "52419b61587f7a79591c4f71a41e403bd3d856dc91d074d61a3a8756e64acf05"
+ "length": 1274,
+ "sha256": "bd2193c2b2bb6ca8c856a1ba9b1adb731c3bb1949ecd6c95fcaa307568872931"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -2760,8 +2760,8 @@
"idempotent": true,
"name": "decide_proposals",
"sql": {
- "length": 1965,
- "sha256": "837cf6dae7da73b5d16feada82438facb111a7644b64ab0b5fe297eb4567faa2"
+ "length": 1578,
+ "sha256": "a6b48e0223120c874556adf9e38fd6a435287730dd417ee578d0fe71db090687"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -3034,8 +3034,8 @@
"idempotent": true,
"name": "links_temporal_state",
"sql": {
- "length": 5310,
- "sha256": "8484772a388ecde131b2fac5638cabc16b0149b6b38d2810637768540f067ad8"
+ "length": 4732,
+ "sha256": "75dbc393feb6485b2a00d9c5a1c67ae3d61382845d00c67a367501d1940dadec"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -3151,8 +3151,8 @@
"idempotent": true,
"name": "decide_review_proposals",
"sql": {
- "length": 2092,
- "sha256": "62d703b01c92f3d530e57f898be5dd3d7f1cbc6270830dd568965ce64c8e602a"
+ "length": 1700,
+ "sha256": "8a20d8dac7096056bb53512bcb34316d15d44582b7d9b0f4f6fff3891c9daac3"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -3164,8 +3164,8 @@
"idempotent": true,
"name": "core_edit_notices",
"sql": {
- "length": 913,
- "sha256": "5088fe988d6819b1a70f7a16f70bb90616dafddf010cc5d38fbaabc2009f4989"
+ "length": 721,
+ "sha256": "d025431d38cc094b0f5ea0b852fa2a8c288a67c10c61cdb5a16c72bee8e7dd1f"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -3385,8 +3385,8 @@
"idempotent": true,
"name": "write_gate",
"sql": {
- "length": 3182,
- "sha256": "d98b50c1f0b1fb54c767333d96e5ab88224f8e3295210013c19a4bfa8a0e7e1b"
+ "length": 2797,
+ "sha256": "2a3434eded166927c0c55b55cb7465cb10494a55404fd6ad9b2b92c72b7f5d17"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -3398,8 +3398,8 @@
"idempotent": true,
"name": "memory_purge",
"sql": {
- "length": 6766,
- "sha256": "3d58b23cedec3767be8d7a8d61fce74fb01063db507fd738680e19580e7a89bc"
+ "length": 5827,
+ "sha256": "9c44f51f5ed5fb1f09690f573de985e81c1a3ba8a7c14c40d86873e5390e818d"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -3424,8 +3424,8 @@
"idempotent": true,
"name": "trust_generation",
"sql": {
- "length": 6684,
- "sha256": "cae6dc9c10cc934511c4a634195cc6847c840bd0a522ff1ea19fbffc2d9a90f5"
+ "length": 6491,
+ "sha256": "db0d07c1c48437dae2729fe3a6db19d352edba7f7b7b3caf88de09c9a926cb8d"
},
"sqlFor": "absent",
"transaction": "absent",