Migration operations

class maykin_common.migration_operations.ResetSequences(*args: Any, **kwargs: Any)

Run the reset_sequences SQL.

Resetting the Postgres sequences makes sure you don’t get Integrity Errors when creating objects because of failing unique constraints. This happens when you create records explicitly with PKs, bypassing the database PK generation. Resetting the sequences makes sure the sequences are aware of the used PKs.

Usage:

>>> from maykin_common.migration_operations import ResetSequences
>>> class Migration(migrations.Migration):
...     dependencies = (...)
...     operations = [
...         ResetSequences(),
...     ]
database_backwards(*args, **kwargs) None
database_forwards(app_label, schema_editor, from_state, to_state) None