Skip to content
Sarj Code Standards

no-noop-migration-down

A migration down section must perform a rollback instead of silently doing nothing.

Why

An empty or SELECT 1 rollback can be recorded as successfully reverted while its schema and data changes remain installed, leaving the migration ledger inconsistent with the database.

Fix

Implement the inverse schema/data change using guarded DDL. If reversal cannot be supported, fail explicitly with an exception instead of recording a successful no-op rollback.

Examples

Before — flagged A successful SELECT leaves the created table installed
migrations/001.sql
-- migrate:up
CREATE TABLE IF NOT EXISTS work (id UUID PRIMARY KEY);
-- migrate:down
SELECT
1;
After — preferred The rollback reverses the schema change
migrations/001.sql
-- migrate:up
CREATE TABLE IF NOT EXISTS work (id UUID PRIMARY KEY);
-- migrate:down
DROP TABLE IF EXISTS work;