[Django] #28785: Tracking migrations

10 views
Skip to first unread message

Django

unread,
Nov 7, 2017, 10:50:40 PM11/7/17
to django-...@googlegroups.com
#28785: Tracking migrations
-----------------------------------------+------------------------
Reporter: Ramez Kabbani | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.11
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 |
-----------------------------------------+------------------------
Migrations exist in django in two locations:
1. In the codebase under app_name/migrations
2. As a db entry in django_migrations

I've come across the following scenario where I expected Django to give an
error but it didn't not.

Assume we have 4 migrations for an app, and migration 1 through 3 are
applied.


{{{
# Content of Postgres DB

32 | app_name | 0001_initial
33 | app_name | 0002_migration2
34 | app_name | 0003_migration3
}}}

All migrations except 0001_initial.py were deleted including the folder
pycache. We then run makemigrations


{{{
# Contents of migration folder after makemigrations was ran.

0001_initial.py 0002_name.py __init__.py __pycache__

# Run makemigrations
No Changes Detected

# Output of showmigrations

app_name
[X] 0001_initial
[X] 0002_name
}}}

Contents of Postgres django_migrations, however, remain unchanged still
with an entry for a third migration. I expected an error in one of the
following commands but received none: makemigrations, migrate,
showmigrations.

Also, migrate --fake app_name 0002_name does not lead to the deletion of
0003_migration3 entry in django_migrations

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

Django

unread,
Nov 8, 2017, 5:07:37 AM11/8/17
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+------------------------------------

Reporter: Ramez Kabbani | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Tomer Chachamu):

* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


Comment:

Agreed that a warning or system check for this situation would be nice.
However, the docs currently suggest a way to turn a squashed migration
into a normal migration, and it looks like any database that has had this
done will then fail the system check. So, we would need:

* A way to turn squashed migrations into normal migrations in the future
that does not cause the system check to fail,
* A solution for old databases to "reset" the system check, or we can just
recommend people add it to `SILENCED_SYSTEM_CHECKS` (which would be a bit
of a shame)

At the least, there might be a good place in the documentation to add a
warning that migration files should not be removed.

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

Django

unread,
Nov 9, 2017, 10:00:35 AM11/9/17
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+--------------------------------------
Reporter: Ramez Kabbani | Owner: Sonu kumar
Type: New feature | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Sonu kumar):

* status: new => assigned
* owner: nobody => Sonu kumar


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

Django

unread,
Dec 28, 2017, 1:37:56 PM12/28/17
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+--------------------------------------
Reporter: Ramez Kabbani | Owner: Sonu kumar
Type: New feature | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


Comment:

A [https://github.com/django/django/pull/9339 PR] adds a check to
makemigrations. It still needs some improvement.

--
Ticket URL: <https://code.djangoproject.com/ticket/28785#comment:3>

Django

unread,
Apr 10, 2021, 6:14:33 AM4/10/21
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+-----------------------------------------
Reporter: Ramez Kabbani | Owner: Manav Agarwal

Type: New feature | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by Manav Agarwal):

* owner: Sonu kumar => Manav Agarwal


--
Ticket URL: <https://code.djangoproject.com/ticket/28785#comment:4>

Django

unread,
Apr 10, 2021, 7:29:20 AM4/10/21
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+-----------------------------------------
Reporter: Ramez Kabbani | Owner: Manav Agarwal
Type: New feature | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by Manav Agarwal):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/28785#comment:5>

Django

unread,
Jun 8, 2021, 4:22:17 AM6/8/21
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+-----------------------------------------
Reporter: Ramez Kabbani | Owner: Manav Agarwal
Type: New feature | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28785#comment:6>

Django

unread,
Apr 13, 2022, 11:15:07 AM4/13/22
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+------------------------------------
Reporter: Ramez Kabbani | Owner: uzaxirr

Type: New feature | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by uzaxirr):

* owner: Manav Agarwal => uzaxirr


--
Ticket URL: <https://code.djangoproject.com/ticket/28785#comment:7>

Django

unread,
May 1, 2022, 7:10:10 AM5/1/22
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+-----------------------------------------
Reporter: Ramez Kabbani | Owner: Abhinav Yadav

Type: New feature | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by Abhinav Yadav):

* owner: Uzair Ali => Abhinav Yadav


--
Ticket URL: <https://code.djangoproject.com/ticket/28785#comment:8>

Django

unread,
Jun 28, 2022, 5:49:41 PM6/28/22
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+-----------------------------------------
Reporter: Ramez Kabbani | Owner: Abhinav Yadav
Type: New feature | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------

Comment (by Adam Johnson):

#26760 added the `--prune` option to `migrate`, to clear up stale entries
from `django_migrations`. Perhaps we no longer need to add a warning now
there's this option.

--
Ticket URL: <https://code.djangoproject.com/ticket/28785#comment:9>

Django

unread,
Jun 29, 2022, 5:08:41 AM6/29/22
to django-...@googlegroups.com
#28785: Tracking migrations
-------------------------------+-----------------------------------------
Reporter: Ramez Kabbani | Owner: Abhinav Yadav
Type: New feature | Status: closed
Component: Migrations | Version: 1.11
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by Carlton Gibson):

* status: assigned => closed
* resolution: => wontfix


Comment:

Agreed, good spot Adam.

Let's mark as wontfix given the `--prune` option, and the difficulty so
far in providing an appropriate patch. (If future-someone wants to re-open
with a PR for whatever is considered missing then that would be OK.)

--
Ticket URL: <https://code.djangoproject.com/ticket/28785#comment:10>

Reply all
Reply to author
Forward
0 new messages