← all rules

require-if-exists

warning

Missing IF [NOT] EXISTS

Why it's unsafe

CREATE TABLE without IF NOT EXISTS is not idempotent — it errors if the table already exists.

Safe rewrite

Add IF NOT EXISTS (CREATE) or IF EXISTS (DROP) so re-running the migration does not error.

Example

Try it in the playground →

Unsafe

CREATE TABLE users (id bigint PRIMARY KEY);

Safe

CREATE TABLE IF NOT EXISTS users (id bigint PRIMARY KEY);