Database architecture skills, docs, and rules for high-demand multi-tenant commerce platforms (PostgreSQL source of truth, Neo4j as derived GraphRAG projection, transactional outbox, RLS-based tenant isolation). Includes live schema introspection workflow via Postgres MCP.
97
97%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Used for Section 3 of the review output when the diagram differs from
current-schema-state.md.
Always four phases. Greenfield diagrams skip this section with the literal note: "Greenfield — initial DDL only, no migration phases needed."
-- Add nullable column(s) and any concurrent index up front.
ALTER TABLE <table> ADD COLUMN <new_col> <type>;
CREATE INDEX CONCURRENTLY idx_<table>_<new_col>
ON <table> (tenant_id, <new_col>);ALTER TABLE ... ADD COLUMN (nullable, no default) →
brief AccessExclusiveLock. CREATE INDEX CONCURRENTLY →
ShareUpdateExclusiveLock, allows concurrent reads/writes.DROP INDEX CONCURRENTLY ...; ALTER TABLE <table> DROP COLUMN <new_col>;WITH batch AS (
SELECT id FROM <table>
WHERE <new_col> IS NULL AND id > $last_id
ORDER BY id LIMIT 5000
)
UPDATE <table> SET <new_col> = <expr>
WHERE id IN (SELECT id FROM batch);UPDATE <table> SET <new_col> = NULL; or restore from
pre-backfill snapshot.-- Application now reads/writes the new column.
-- Promote any expand-time index to a constraint without rewriting the table.
ALTER TABLE <table>
ADD CONSTRAINT uq_<table>_<new_col>
UNIQUE USING INDEX idx_<table>_<new_col>;ALTER TABLE ... USING INDEX upgrades the existing index
in place. No table rewrite.ALTER TABLE <table> DROP CONSTRAINT uq_<table>_<new_col>;ALTER TABLE <table> ALTER COLUMN <new_col> SET NOT NULL;
ALTER TABLE <table> DROP COLUMN <old_col>;SET NOT NULL revalidates rows under brief
AccessExclusiveLock; column drop is metadata-only.ALTER TABLE <table> ALTER COLUMN <new_col> DROP NOT NULL;
Dropped column cannot be restored without backup — keep one before Phase 4.docs
skills
adr-drafting
commerce-database-architecture
graph-rag-boundary-review
mermaid-diagram-review
outbox-and-eventing-design
postgres-schema-introspection
schema-evolution-workflow