refactor(schema): fan desired-state schema out to one file per table (#8131)

This commit is contained in:
Luke Tornquist
2026-10-08 08:47:44 -04:00
committed by GitHub
parent f8bf2c529c
commit 745501962e
154 changed files with 2403 additions and 2110 deletions

View File

@@ -0,0 +1,24 @@
-- Fleet-wide writers filter candidates through this VOLATILE predicate in
-- the mutating statement so fenced tenants are skipped before row triggers run.
CREATE FUNCTION community_write_allowed(target UUID) RETURNS BOOLEAN
LANGUAGE plpgsql VOLATILE AS $$
DECLARE
lifecycle TEXT;
BEGIN
IF current_setting('transaction_isolation') <> 'read committed' THEN
RAISE EXCEPTION 'community writes require READ COMMITTED isolation'
USING ERRCODE = 'invalid_transaction_state';
END IF;
IF target IS NULL THEN
RETURN true;
END IF;
PERFORM pg_advisory_xact_lock_shared(community_deletion_lock_key(target));
SELECT deletion_state
INTO lifecycle
FROM communities
WHERE id = target;
RETURN FOUND AND lifecycle = 'active';
END
$$;