makemigrate adds multiple migrations.AddField for same model (django 1.7.1)

77 visualizzazioni
Passa al primo messaggio da leggere

pjotr

da leggere,
21 dic 2014, 14:36:2921/12/14
a django...@googlegroups.com
Hi,

I have a django model that I just added six new fields to. I ran makemigrations and after that noticed when we ran our rehearsal upgrade with dump of the production database that things took longer than we expected, and checked the processlist. We saw that there were six alter table statements that was executed after each other, each taking around 15 minutes to run.

My expectations were that the migration framework would optimise this and only execute one alter table statement. But obviously it was not. Or is there a bug? :)

Are there anyway to fix this, without having to change the migration and perform the alter table statement with pure SQL?

DB: MySQL
Django 1.7.1

The migrations generated were six of these (only showing one to reduce post size):

migrations.AddField(
model_name='mymodel',
name='field_a',
field=models.BigIntegerField(help_text=b'Blablabla', null=True, db_index=True),
preserve_default=True,
),

Regards, Peter Lauri

pjotr

da leggere,
21 dic 2014, 18:27:0621/12/14
a django...@googlegroups.com
Just realized the subject was wrong, it should be makemigrations , not makemigrate

Collin Anderson

da leggere,
22 dic 2014, 22:46:4222/12/14
a django...@googlegroups.com
Hi,

You're just using one database?

Are all 6 ALTER statements identical?

Collin

pjotr

da leggere,
23 dic 2014, 06:04:5523/12/14
a django...@googlegroups.com
Sorry, all the ALTER statements are identical except the FIELDNAME. It adds 6 new fields.

Collin Anderson

da leggere,
26 dic 2014, 15:54:5226/12/14
a django...@googlegroups.com
Ohh, I see. Yes, this looks like a possible spot for optimization. I wouldn't really call it a "bug", but a "cleanup/optimization". You could probably open a ticket about it.

pjotr

da leggere,
22 gen 2015, 13:48:5422/01/15
a django...@googlegroups.com
Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi