Closed jgkim closed 12 years ago
For whatever reason, it looks like south is having trouble running the migration on MySQL. Is there anything in the DB error logs? By default they should be in /var/lib/mysql/server.hostname.err
.
Also, what version are you running of:
I'm unable to reproduce this on:
The following line is added to the DB error log
120406 18:54:51 [Warning] Invalid (old?) table or database name '#sql-135e_17'
The versions I'm running of are:
It works without any errors in the following circumstance:
It seems the problem was due to South 0.7.3, and it works smoothly now with South 0.7.4.
Interesting. Well it's good to have this as a reference of the incompatibility. Glad you cleared it up.
I'd like to note here, for anyone searching around for this, using
When I work with a project and start adding up migrations, at some point, the database gets reliably messed up. Adding an example would be too much work (contact me if you need a sample app), but basically what happens is that I get a mysql error like
(1061, "Duplicate key name 'fragile_assetdata_asset_id_7f82caf7_uniq'")
Where fragile is django app, assetdata.asset_id is a foreign key to asset.id, which I'm changing from 1:n to 1:1 field.
So currently it happens with this migration
# Changing field 'AssetData.asset'
db.alter_column(u'fragile_assetdata', 'asset_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['fragile.Asset'], unique=True))
# Adding unique constraint on 'AssetData', fields ['asset']
db.create_unique(u'fragile_assetdata', ['asset_id'])
Previously it happened with this migration:
db.alter_column(u'fragile_currentprogress', 'asset_id',
self.gf('django.db.models.fields.related.ForeignKey')(to=orm['fragile.Asset'],
null=True, blank=True))
I'm suspecting the problem is in MySQL itself, but trying a few different versions brought the same result. Restoring the db files from backup did the same.
However, it doesn't seem to be happening when I apply the migrations one by one (i.e. it works when I'm developing a new feature, migrating, developing something else, migrating...). So I'm suspecting some sort of racing condition in MySQL.
My workaround was to flatten the migration, however unpleasant it might be, at least I don't have production code running yet...
As a followup to http://mail.chip.org/pipermail/indivohealth/2012-March/000929.html, I'm opening this issue.
When I run the reset script (
utils/reset.py
), it fails with the following message:The sequence that I took to avoid the error was:
south
insettings.py
.python manage.py syncdb
south
insettings.py
.python manage.py syncdb
python utils/reset.py --no-syncdb -b -c