[Django] #35656: Make migration Command doesn't allow changing the autodetector

22 views
Skip to first unread message

Django

unread,
Aug 3, 2024, 2:28:03 PM8/3/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed | Owner: leondaz
Ibrahim |
Type: | Status: assigned
Cleanup/optimization |
Component: | Version:
Migrations | Keywords: migrations,
Severity: Normal | makemigrations, commands
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
I had a situation where I want to subclass the Autodetector to add more
operations that the ones in Django, an operation that does not create a
row, but rather, a table (different model)

This line is copied from
`django/django/core/management/commands/makemigrations.py`



{{{
# Detect changes
changes = autodetector.changes(
graph=loader.graph,
trim_to_apps=app_labels or None,
convert_apps=app_labels or None,
migration_name=self.migration_name,
)
}}}

The suggested approach is to save the `autodetector` on the class level,
and subclasses can override it to use their custom version.


P.S: I'm not sure if this is considered a feature or an optimization
--
Ticket URL: <https://code.djangoproject.com/ticket/35656>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 3, 2024, 2:28:40 PM8/3/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: leondaz
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version:
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage:
makemigrations, commands | Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Ibrahim):

* needs_docs: 0 => 1

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

Django

unread,
Aug 3, 2024, 3:10:33 PM8/3/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: leondaz
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version:
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage:
makemigrations, commands | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Ibrahim):

* needs_docs: 1 => 0

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

Django

unread,
Aug 4, 2024, 4:56:23 AM8/4/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: leondaz
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage: Accepted
makemigrations, commands |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* easy: 1 => 0
* stage: Unreviewed => Accepted
* version: => dev

Comment:

I also do think having a way to specify a custom autodetector class would
be an improvement. However, the autodetector class should be the same in
`makemigrations` as the one in `migrate` command, so it might not be
trivial to define it so it doesn't require the user to customize the class
separately in both commands.
--
Ticket URL: <https://code.djangoproject.com/ticket/35656#comment:3>

Django

unread,
Aug 4, 2024, 10:17:04 AM8/4/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: leondaz
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage: Accepted
makemigrations, commands |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ahmed Ibrahim):

Replying to [comment:3 Claude Paroz]:
> I also do think having a way to specify a custom autodetector class
would be an improvement. However, the autodetector class should be the
same in `makemigrations` as the one in `migrate` command, so it might not
be trivial to define it so it doesn't require the user to customize the
class separately in both commands.

Thank you my friend for accepting the ticket and also stating the
difficulty of the ticket, yes it bumped up a bit, I will do my best and
mention the pr so that you may have a look if you don't mind
--
Ticket URL: <https://code.djangoproject.com/ticket/35656#comment:4>

Django

unread,
Aug 4, 2024, 11:22:40 AM8/4/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: leondaz
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage: Accepted
makemigrations, commands |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Ibrahim):

* has_patch: 0 => 1

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

Django

unread,
Aug 4, 2024, 11:33:44 AM8/4/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: leondaz
Type: | Status: assigned
Cleanup/optimization |
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage: Accepted
makemigrations, commands |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ahmed Ibrahim):

https://github.com/django/django/pull/18445
--
Ticket URL: <https://code.djangoproject.com/ticket/35656#comment:6>

Django

unread,
Aug 13, 2024, 4:30:22 AM8/13/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: leondaz
Type: New feature | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage: Accepted
makemigrations, commands |
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1
* needs_docs: 0 => 1
* needs_tests: 0 => 1
* type: Cleanup/optimization => New feature

Comment:

Marking as a new feature as we should highlight this change in the
docs/release notes for people to use it. It also should have tests
--
Ticket URL: <https://code.djangoproject.com/ticket/35656#comment:7>

Django

unread,
Oct 11, 2024, 6:19:16 AM10/11/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: Ahmed
| Ibrahim
Type: New feature | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage: Accepted
makemigrations, commands |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 1 => 0
* needs_docs: 1 => 0
* needs_tests: 1 => 0
* owner: leondaz => Ahmed Ibrahim

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

Django

unread,
Oct 15, 2024, 7:10:06 AM10/15/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: Ahmed
| Ibrahim
Type: New feature | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage: Ready for
makemigrations, commands | 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/35656#comment:9>

Django

unread,
Oct 15, 2024, 10:39:21 AM10/15/24
to django-...@googlegroups.com
#35656: Make migration Command doesn't allow changing the autodetector
-------------------------------------+-------------------------------------
Reporter: Ahmed Ibrahim | Owner: Ahmed
| Ibrahim
Type: New feature | Status: closed
Component: Migrations | Version: dev
Severity: Normal | Resolution: fixed
Keywords: migrations, | Triage Stage: Ready for
makemigrations, commands | 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:"06bf06a911695c5c84f746742f764c040e237ece" 06bf06a]:
{{{#!CommitTicketReference repository=""
revision="06bf06a911695c5c84f746742f764c040e237ece"
Fixed #35656 -- Added an autodetector attribute to the makemigrations and
migrate commands.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35656#comment:10>
Reply all
Reply to author
Forward
0 new messages