Skip to content

idempotent-ddl

DDL without IF [NOT] EXISTS — migrations must be safe to re-run.

Why

A partially applied migration may be retried, so unconditional object creation or removal can fail before recovery completes.

Fix

Use the supported IF NOT EXISTS or IF EXISTS form for the DDL statement.

Examples

Before — flagged Table creation that fails on replay
migrations/001_orders.sql
CREATE TABLE orders (id BIGINT PRIMARY KEY);
After — preferred Replay-safe table creation
migrations/001_orders.sql
CREATE TABLE IF NOT EXISTS orders (id BIGINT PRIMARY KEY);