This all refers to PostgreSQL, on other databases it will probably be different.
-
Create the new User model as an exact copy of
django.contrib.auth.models.User
(we assume it will beuser.User
then) -
Create the migrations and commit them
-
Run the following SQL to simulate that the migration has run
SELECT * FROM django_migrations_id_seq; ALTER TABLE django_migrations DROP CONSTRAINT django_migrations_pkey; UPDATE django_migrations SET id = id + 1; ALTER TABLE django_migrations ADD CONSTRAINT django_migrations_pkey PRIMARY KEY (id); INSERT INTO django_migrations (id,app, name, applied) VALUES (1, 'user', '0001_initial', '1970-01-01 00:00:00.000000+00'); ALTER SEQUENCE django_migrations_id_seq RESTART WITH <<<fill-in>>>;
This leads to issues with the next migrations.
It fails with the unfortunate situation that the migration will be applied but not logged. This can be fixed like this: