Opened 3 days ago

Last modified 2 days ago

#36274 assigned New feature

MigrationWriter does not support writing run_before

Reported by: Mikuláš Poul Owned by: Mikuláš Poul
Component: Migrations Version: 5.1
Severity: Normal Keywords: migrations migrationswriter run_before
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

According to the ticket's flags, the next step(s) to move this issue forward are:

  • For anyone except the patch author to review the patch using the patch review checklist and either mark the ticket as "Ready for checkin" if everything looks good, or leave comments for improvement and mark the ticket as "Patch needs improvement".

Change History (5)

comment:1 by Simon Charette, 3 days ago

Easy pickings: unset
Triage Stage: UnreviewedAccepted
Type: BugNew feature

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.

comment:2 by Mikuláš Poul, 3 days ago

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?

comment:3 by Simon Charette, 3 days ago

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 for now, I think it might be worth making an audit of all documented Migration attributes and adding for them yes.

Last edited 3 days ago by Simon Charette (previous) (diff)

comment:4 by Mikuláš Poul, 3 days ago

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)

comment:5 by JaeHyuckSa, 2 days ago

Owner: set to Mikuláš Poul
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top