[Django] #34336: Reverting a migration with `replaces = [...]` set does not revert it

9 views
Skip to first unread message

Django

unread,
Feb 13, 2023, 9:15:36 AM2/13/23
to django-...@googlegroups.com
#34336: Reverting a migration with `replaces = [...]` set does not revert it
-------------------------------------------+------------------------
Reporter: Thomas Chaumeny | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
I have four migrations in an app. In migration 4, I have `replaces =
[("my_app", "0002_foo")]`.

When I migrate back from the state where all migration are applied to the
first migration, it says that the migration 4 has been reverted.

However, that migration is still marked as passed in the
`django_migrations` table and when I try to migrate again to the state 4
it fails saying that migration 4 was already applied.

Is rollbacking a migration with `replaces` set supported? How is that
supposed to behave, regarding the migration and the one it replaces?

--
Ticket URL: <https://code.djangoproject.com/ticket/34336>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 13, 2023, 9:16:25 AM2/13/23
to django-...@googlegroups.com
#34336: Reverting a migration with `replaces = [...]` set does not revert it
---------------------------------+--------------------------------------

Reporter: Thomas Chaumeny | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by Thomas Chaumeny:

Old description:

> I have four migrations in an app. In migration 4, I have `replaces =
> [("my_app", "0002_foo")]`.
>
> When I migrate back from the state where all migration are applied to the
> first migration, it says that the migration 4 has been reverted.
>
> However, that migration is still marked as passed in the
> `django_migrations` table and when I try to migrate again to the state 4
> it fails saying that migration 4 was already applied.
>
> Is rollbacking a migration with `replaces` set supported? How is that
> supposed to behave, regarding the migration and the one it replaces?

New description:

I have four migrations in an app. In migration 4, I have `replaces =
[("my_app", "0002_foo")]`.

When I migrate back from the state where all migration are applied to the
first migration, it says that the migration 4 has been reverted.

However, that migration is still marked as passed in the
`django_migrations` table and when I try to migrate again to the state 4
it fails saying that migration 4 was already applied.

Is rollbacking a migration where `replaces` is set supported? How is that


supposed to behave, regarding the migration and the one it replaces?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34336#comment:1>

Django

unread,
Feb 13, 2023, 11:22:42 PM2/13/23
to django-...@googlegroups.com
#34336: Reverting a migration with `replaces = [...]` set does not revert it
----------------------------+--------------------------------------
Reporter: Thomas C | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo


Comment:

> However, that migration is still marked as passed in the
django_migrations table and when I try to migrate again to the state 4 it
fails saying that migration 4 was already applied.

Reverting squashed migrations works for me. Did you manually add the
`replaces` attribute? Please reopen the ticket if you can debug your issue
and provide a small project that reproduces it.

--
Ticket URL: <https://code.djangoproject.com/ticket/34336#comment:2>

Reply all
Reply to author
Forward
0 new messages