[Django] #36274: MigrationWriter does not support writing run_before

26 views
Skip to first unread message

Django

unread,
Mar 23, 2025, 11:41:26 AM3/23/25
to django-...@googlegroups.com
#36274: MigrationWriter does not support writing run_before
-------------------------------------+-------------------------------------
Reporter: Mikuláš Poul | Type: Bug
Status: new | Component:
| Migrations
Version: 5.1 | Severity: Normal
Keywords: migrations | Triage Stage:
migrationswriter run_before | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
The `MigrationWriter` class implements writing a instance of
`django.db.migrations.migration.Migration`. It supports serializing all
the options it could have except for `run_before`. I recently made a PR
for a third-party package on remaking migrations (a form of squashing),
and had to subclass the writer to be able to include `run_before`. I think
`MigrationWriter` should support all options available on `Migration`, to
make working with migrations easier.
--
Ticket URL: <https://code.djangoproject.com/ticket/36274>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 23, 2025, 11:51:04 AM3/23/25
to django-...@googlegroups.com
#36274: MigrationWriter does not support writing run_before
-------------------------------------+-------------------------------------
Reporter: Mikuláš Poul | Owner: (none)
Type: New feature | Status: new
Component: Migrations | Version: 5.1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
migrationswriter run_before |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* easy: 1 => 0
* stage: Unreviewed => Accepted
* type: Bug => New feature

Comment:

I'm not sure I would qualify it as a bug given the framework itself
doesn't make use of this option internally when creating migrations so it
had little use in adding support for it.

It's a small non-invasive feature request though, as patch demonstrates,
so I don't think it warrants a larger discussion on the forum.
--
Ticket URL: <https://code.djangoproject.com/ticket/36274#comment:1>

Django

unread,
Mar 23, 2025, 11:55:12 AM3/23/25
to django-...@googlegroups.com
#36274: MigrationWriter does not support writing run_before
-------------------------------------+-------------------------------------
Reporter: Mikuláš Poul | Owner: (none)
Type: New feature | Status: new
Component: Migrations | Version: 5.1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
migrationswriter run_before |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mikuláš Poul):

That is very fair, I guess it is more a feature request then a bug! I also
see that `atomic` is not supported in the writer, would you like me to add
the support for `atomic` while I am there?
--
Ticket URL: <https://code.djangoproject.com/ticket/36274#comment:2>

Django

unread,
Mar 23, 2025, 12:09:32 PM3/23/25
to django-...@googlegroups.com
#36274: MigrationWriter does not support writing run_before
-------------------------------------+-------------------------------------
Reporter: Mikuláš Poul | Owner: (none)
Type: New feature | Status: new
Component: Migrations | Version: 5.1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
migrationswriter run_before |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

> I also see that `atomic` is not supported in the writer, would you like
me to add the support for `atomic` while I am there?

If we're going to add support for `run_before`, even if unused by the
framework itself, I think it might be worth making an audit of all
documented `Migration` attributes and adding for them yes.
--
Ticket URL: <https://code.djangoproject.com/ticket/36274#comment:3>

Django

unread,
Mar 23, 2025, 1:10:45 PM3/23/25
to django-...@googlegroups.com
#36274: MigrationWriter does not support writing run_before
-------------------------------------+-------------------------------------
Reporter: Mikuláš Poul | Owner: (none)
Type: New feature | Status: new
Component: Migrations | Version: 5.1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
migrationswriter run_before |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mikuláš Poul):

I've updated my PR to include atomic support as well. After adding
`run_before` and `atomic` that should be all of the properties defined on
`Migration` (going by
https://github.com/django/django/blob/cd03e8e2d698e9ccefae2f7687a0400329e6cbe6/django/db/migrations/migration.py#L27-L53)
--
Ticket URL: <https://code.djangoproject.com/ticket/36274#comment:4>

Django

unread,
Mar 24, 2025, 3:40:35 AM3/24/25
to django-...@googlegroups.com
#36274: MigrationWriter does not support writing run_before
-------------------------------------+-------------------------------------
Reporter: Mikuláš Poul | Owner: Mikuláš
| Poul
Type: New feature | Status: assigned
Component: Migrations | Version: 5.1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
migrationswriter run_before |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by JaeHyuckSa):

* owner: (none) => Mikuláš Poul
* status: new => assigned

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

Django

unread,
Apr 15, 2025, 6:53:54 AM4/15/25
to django-...@googlegroups.com
#36274: MigrationWriter does not support writing run_before
-------------------------------------+-------------------------------------
Reporter: Mikuláš Poul | Owner: Mikuláš
| Poul
Type: New feature | Status: assigned
Component: Migrations | Version: 5.1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Ready for
migrationswriter run_before | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

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

Django

unread,
Apr 16, 2025, 4:21:00 AM4/16/25
to django-...@googlegroups.com
#36274: MigrationWriter does not support writing run_before
-------------------------------------+-------------------------------------
Reporter: Mikuláš Poul | Owner: Mikuláš
| Poul
Type: New feature | Status: closed
Component: Migrations | Version: 5.1
Severity: Normal | Resolution: fixed
Keywords: migrations | Triage Stage: Ready for
migrationswriter run_before | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

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

Comment:

In [changeset:"494d2dc316fc1d849b6a1af97575d293f856a84c" 494d2dc]:
{{{#!CommitTicketReference repository=""
revision="494d2dc316fc1d849b6a1af97575d293f856a84c"
Fixed #36274 -- Added support for run_before and atomic in
MigrationWriter.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36274#comment:7>
Reply all
Reply to author
Forward
0 new messages