Skip to content
Sarj Code Standards

no-migration-comment-cruft

Commented-out SQL, decorative banners, untracked debt markers, and long implementation narration must be removed.

Why

Disabled statements drift while version control preserves their history, decorative dividers obscure migration structure, and debt without a durable owner silently persists.

Fix

Execute or delete disabled SQL, delete decorative dividers, and resolve debt or attach a durable issue reference; delete long implementation narration. Retain concise operational constraints, rollback instructions, and tool directives.

Examples

Before — flagged Disabled SQL statement
migrations/001.sql
-- DROP TABLE legacy_events;
SELECT
1;
After — preferred Owned rollback instruction records an operational constraint
migrations/001.sql
-- Roll back by restoring snapshot OPS-812.
SELECT
1;
Autofix output
migrations/001.sql
SELECT
1;
Before — flagged Migration comments narrate the table declarations
migrations/001.sql
-- Create the custom_integration table used by the application.
-- The table stores each configured integration for an organization.
-- The next statement defines its identifier and display name.
-- The final statement creates those columns in the database.
CREATE TABLE IF NOT EXISTS integration (id BIGINT PRIMARY KEY, name TEXT);
After — preferred Concrete operational constraints remain local
migrations/001.sql
-- Backfill no more than 1000 rows per transaction.
-- Keep lock_timeout at 3 seconds while API-812 writes continuously.
-- Wait for replica lag to return below 500 ms before the next batch.
-- Roll back by dropping the new index concurrently.
SET
lock_timeout = '3s';
SELECT
1;
Before — flagged A long run consists entirely of disabled SQL declarations
migrations/001.sql
-- CREATE TABLE access (id BIGINT PRIMARY KEY, permission TEXT);
-- CREATE TABLE users (id BIGINT PRIMARY KEY, name TEXT);
-- CREATE TABLE groups (id BIGINT PRIMARY KEY, name TEXT);
-- CREATE TABLE teams (id BIGINT PRIMARY KEY, name TEXT);
-- CREATE TABLE accounts (id BIGINT PRIMARY KEY, name TEXT);
After — preferred Executable declarations do not narrate disabled source
migrations/001.sql
CREATE TABLE access (id BIGINT PRIMARY KEY, permission TEXT);
CREATE TABLE users (id BIGINT PRIMARY KEY, name TEXT);
CREATE TABLE groups (id BIGINT PRIMARY KEY, name TEXT);
CREATE TABLE teams (id BIGINT PRIMARY KEY, name TEXT);
CREATE TABLE accounts (id BIGINT PRIMARY KEY, name TEXT);

Formerly: excessive-commentary, no-comment-cruft, no-long-migration-narration