Rules
50 ways a migration can hurt production.
Every check Fronelta runs on a pull request, why it matters in PostgreSQL, and the safer way to write it. Critical and High findings block the merge by default; each project can change that.
- [critical]
- Data loss or a broken deploy is likely.
- [high]
- Blocks reads or writes on a busy table, or fails on real data.
- [medium]
- Risky at scale or easy to get wrong; worth a look.
- [low]
- Good practice; rarely a problem on its own.
- [info]
- For your information; never affects the result.
Destructive
Statements that delete data for good. They're often intended, so Fronelta asks you to confirm them rather than guess.
- FRN101Table droppedDropping a table that already exists deletes its data.[critical]
- FRN102Column droppedDropping a column deletes its data and breaks clients that still select it.[high]
- FRN103Schema droppedDropping a schema removes every object inside it.[critical]
- FRN104Table truncatedTRUNCATE deletes every row of a table that already exists.[critical]
- FRN105UPDATE or DELETE without WHEREThe statement touches every row of an existing table.[medium]
Compatibility
Renames and removals that break application code still running against the old names during a deploy.
- FRN111Table renamedClients that use the old table name fail after a rename.[high]
- FRN112Column renamedClients that use the old column name fail after a rename.[high]
- FRN113View or function changed under clientsDropping or renaming a view or function used by clients breaks them.[medium]
- FRN114Dependent objects dropped with CASCADEDropping a table or column also removed a view, function, policy or another table's key that used it.[high]
Indexes
Building or dropping an index the plain way locks the table; the CONCURRENTLY forms don't block writes.
Rewrites
Changes that make PostgreSQL copy the whole table while it's locked. Time grows with table size.
- FRN301Column type change rewrites the tableChanging a column type usually rewrites the whole table under an ACCESS EXCLUSIVE lock.[high]
- FRN302Column added with a volatile defaultA default like random() or clock_timestamp() forces a table rewrite.[high]
- FRN303Table switched between LOGGED and UNLOGGEDSET LOGGED / SET UNLOGGED rewrites the table.[high]
- FRN304Stored generated column addedA STORED generated column is computed for every existing row.[high]
- FRN305Identity column added to an existing tableAdding an identity column rewrites the table.[high]
Types
Column types with a better default in PostgreSQL. Advice only: they show as info unless your policy raises them.
- FRN311Integer column may run out of valuesinteger and smallint columns hold far fewer values than bigint.[info]
- FRN312Timestamp without time zonetimestamp stores a wall-clock time with no zone, so its meaning depends on the writer's settings.[info]
- FRN313Length-limited text typevarchar(n) and char(n) make a later length change a migration of its own.[info]
Constraints
New constraints are checked against every existing row while a lock is held, unless added NOT VALID and validated later.
Locking
A statement that queues for a strong lock blocks every query behind it. A lock_timeout makes it give up instead.
Data-dependent
Changes that succeed or fail depending on the rows already in production (duplicates, NULLs).
- FRN501Unique constraint added to existing dataAdding UNIQUE can fail on duplicates and builds its index under a lock.[high]
- FRN502SET NOT NULL on an existing columnSET NOT NULL scans the table under an ACCESS EXCLUSIVE lock and fails on any NULL.[high]
- FRN503NOT NULL column added without a defaultFails on any table that already has rows.[high]
Transactions
How the migration tool wraps each file in a transaction, and statements that can't run inside one.
Security
Who can read and change table rows: grants, row-level security and its policies, compared before and after the migration.
- FRN121Privileges granted to PUBLICEvery role, including ones created later, gets a privilege on a table or view.[high]
- FRN122Row-level security turned offA table that had row-level security enabled (or forced) no longer does.[high]
- FRN123Row-level security policy droppedA policy was removed from a table that still exists.[medium]
History
Migrations already applied in production must not change, and new ones must sort after them.
- FRN701Already-merged migration editedEditing a migration that's already on the base branch diverges from production history.[high]
- FRN702Migration version out of orderA version lower than the latest on the base branch may be skipped by your tool.[medium]
- FRN703Production schema drifted from the migrationsProduction has a schema object the migrations don't create, lacks one they do, or defines it differently.[high]
- FRN704Down migration doesn't undo the changeRunning the down migrations after this pull request's migrations failed, or left the schema different from before.[medium]
- FRN705No down migrationA new migration has no down migration, so its reversibility wasn't checked.[info]
- FRN706Migrations don't match schema.hclThe schema the migrations build differs from the one declared in schema.hcl.[high]
- FRN708Rollback did not restore dataRow fingerprints differ after the down migrations.[high]
Execution evidence
What Fronelta measured when it ran the migration on a seeded copy: locks held, rewrites, timings and errors.
- FRN801Table rewritten during executionFronelta observed the table's storage being rewritten.[high]
- FRN802ACCESS EXCLUSIVE lock heldA lock that blocks all reads and writes was held on an existing table.[high]
- FRN803Slow statementA statement ran longer than the threshold at the seeded row count.[medium]
- FRN804Statement failedPostgreSQL returned an error while executing the migration.[critical]
Engine
Files Fronelta couldn't fully analyse, and suppression comments it couldn't apply.
- FRN707schema.hcl can't be usedschema.hcl has a mistake, or the SQL it declares doesn't run on PostgreSQL.[high]
- FRN901Syntax errorThe file isn't valid PostgreSQL.[critical]
- FRN902Dynamic SQL not analysed staticallyDO blocks and EXECUTE strings can't be checked before running.[info]
- FRN903Invalid suppression commentA fronelta:allow comment names an unknown rule or has no reason.[low]