MP059WARNINGFree

sequence-not-reset-after-data-migration

What It Detects

INSERT with explicit integer IDs without resetting the sequence may cause duplicate key errors.

Why It's Dangerous

When you seed data with explicit IDs, the sequence counter stays at its initial value. The next auto-generated INSERT picks a low ID that already exists, causing "duplicate key violates unique constraint."

Bad Example

INSERT INTO users (id, name) VALUES (1, 'Alice');
INSERT INTO users (id, name) VALUES (2, 'Bob');
-- Next auto-generated INSERT gets id=1!

Good Example

INSERT INTO users (id, name) VALUES (1, 'Alice');
INSERT INTO users (id, name) VALUES (2, 'Bob');
SELECT setval(pg_get_serial_sequence('users', 'id'),
  COALESCE(MAX(id), 1)) FROM users;

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP059: false

Or change its severity:

# .migrationpilotrc.yml
rules:
  MP059:
    severity: warning