[Django] #26114: Removing Meta.db_table generates migration with wrong rename (None)

10 views
Skip to first unread message

Django

unread,
Jan 21, 2016, 11:27:16 AM1/21/16
to django-...@googlegroups.com
#26114: Removing Meta.db_table generates migration with wrong rename (None)
----------------------------+--------------------
Reporter: dvinegla | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
{{{
# myapp.models.py

#Old model
class MyModel(models.Model):
...
class Meta:
db_table = 'legacy_table'

#New model
class MyModel(models.Model):
...

# makemigrations output:
- Rename table for mymodel to None

# sqlmigrate output:
BEGIN;
--
-- Rename table for mymodel to None
--
RENAME TABLE `legacy_table` TO `myapp_mymodel`;

COMMIT;

}}}

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

Django

unread,
Jan 21, 2016, 11:38:54 AM1/21/16
to django-...@googlegroups.com
#26114: Removing Meta.db_table generates migration with wrong rename in comment
(None)
----------------------------+------------------------------------

Reporter: dvinegla | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.9
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 timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
* stage: Unreviewed => Accepted


Comment:

I think we
[https://github.com/django/django/blob/fb4272f0e6bbdaa3e19ed5fde59fdb5ab5a33baf/django/db/migrations/operations/models.py#L316-L317
don't have the needed information to put the actual name] in the comment,
but perhaps we could replace `None` with something like `(default)`.

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

Django

unread,
Jul 2, 2016, 3:40:08 PM7/2/16
to django-...@googlegroups.com
#26114: Removing Meta.db_table generates migration with wrong rename in comment
(None)
----------------------------+------------------------------------
Reporter: dvinegla | Owner: PREM1980
Type: Bug | Status: assigned
Component: Migrations | Version: 1.9

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 PREM1980):

* owner: nobody => PREM1980
* status: new => assigned


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

Django

unread,
Jul 2, 2016, 7:53:48 PM7/2/16
to django-...@googlegroups.com
#26114: Removing Meta.db_table generates migration with wrong rename in comment
(None)
----------------------------+------------------------------------
Reporter: dvinegla | Owner: PREM1980
Type: Bug | Status: assigned
Component: Migrations | Version: 1.9

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
----------------------------+------------------------------------

Comment (by PREM1980):

I'm thinking the following, please review and provide your comments.


When someone provides "None" as the new table name, we won't detect that
as a change and just ignore it.

https://github.com/django/django/blob/fb4272f0e6bbdaa3e19ed5fde59fdb5ab5a33baf/django/db/migrations/autodetector.py#L962

This is the new change that works.

if old_db_table_name != new_db_table_name and new_db_table_name != None:
self.add_operation(
app_label,
operations.AlterModelTable(
name=model_name,
table=new_db_table_name,
)
)

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

Django

unread,
Jul 4, 2016, 6:21:57 PM7/4/16
to django-...@googlegroups.com
#26114: Removing Meta.db_table generates migration with wrong rename in comment
(None)
----------------------------+------------------------------------
Reporter: dvinegla | Owner: PREM1980
Type: Bug | Status: assigned
Component: Migrations | Version: 1.9

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
----------------------------+------------------------------------

Comment (by timgraham):

The change I proposed in comment 1 is about modifying
`AlterModelTable.describe()`. The autodetector shouldn't be changed like
that because then a migration changing the table name back to the default
wouldn't be created.

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

Django

unread,
Jul 16, 2016, 8:49:11 PM7/16/16
to django-...@googlegroups.com
#26114: Removing Meta.db_table generates migration with wrong rename in comment
(None)
----------------------------+------------------------------------
Reporter: dvinegla | Owner: PREM1980
Type: Bug | Status: assigned
Component: Migrations | Version: 1.9

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
----------------------------+------------------------------------

Comment (by PREM1980):

The changes are made and here is the Github link.

https://github.com/PREM1980/django

Branch - ticket_26114

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

Django

unread,
Jul 20, 2016, 9:43:55 PM7/20/16
to django-...@googlegroups.com
#26114: Removing Meta.db_table generates migration with wrong rename in comment
(None)
----------------------------+------------------------------------
Reporter: dvinegla | Owner: PREM1980
Type: Bug | Status: assigned
Component: Migrations | Version: 1.9

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 timgraham):

* has_patch: 0 => 1


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

Django

unread,
Jul 28, 2016, 10:35:37 AM7/28/16
to django-...@googlegroups.com
#26114: Removing Meta.db_table generates migration with wrong rename in comment
(None)
----------------------------+------------------------------------
Reporter: dvinegla | Owner: PREM1980
Type: Bug | Status: closed
Component: Migrations | Version: 1.9
Severity: Normal | Resolution: fixed

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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"5da7e3f7fd24381195e557d807118130ddbc5152" 5da7e3f]:
{{{
#!CommitTicketReference repository=""
revision="5da7e3f7fd24381195e557d807118130ddbc5152"
Fixed #26114 -- Fixed AlterModelTable.describe() if db_table is None.
}}}

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

Reply all
Reply to author
Forward
0 new messages