fix evildmp/Arkestra#68 #70

Merged
merged 2 commits into from Mar 13, 2013

Conversation

Projects
None yet
2 participants
Contributor

darbula commented Mar 12, 2013

This one should fix issue #68. I have tested it with sqllite and mysql and it works just as it should.

darbula closed this Mar 12, 2013

darbula reopened this Mar 12, 2013

@evildmp evildmp commented on the diff Mar 12, 2013

...rations/0005_delete_column_personlite_title_backup.py
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ db.delete_column('contacts_and_people_personlite', 'title_backup_id')
+ # Renaming column for 'PersonLite.title' to match new field type.
+ db.rename_column('contacts_and_people_personlite', 'title', 'title_id')
+ # Changing field 'PersonLite.title'
+ db.alter_column('contacts_and_people_personlite', 'title_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contacts_and_people.Title'], null=True, on_delete=models.SET_NULL))
+ # Adding index on 'PersonLite', fields ['title']
+ #db.create_index('contacts_and_people_personlite', ['title_id'])
@evildmp

evildmp Mar 12, 2013

Owner

It's not clear to me why firstly an index is being created (I haven't seen it on other similar ForeignKeys) and secondly why you have chosen to comment it out.

@darbula

darbula Mar 12, 2013

Contributor

The migrations are created semi-automatically by editing south --auto migrations. South is creating an index for all foreign keys as it is useful. This part is commented out since there is a problem with sqllite when field is given foreign key constraint. I have checked and in mysql after migration title_id is index.

Owner

evildmp commented Mar 12, 2013

This looks great, thanks, I will test it this morning.

Owner

evildmp commented Mar 12, 2013

That's all looking good. It worked fine with MySQL, anyway. I'll make a couple of notes and merge it.

Can you tell me how you'd like to be credited in https://github.com/evildmp/Arkestra/blob/develop/CONTRIBUTORS.txt?

@darbula darbula fix evildmp/Arkestra#68 clean syncdb and migrate was failing on mysql…
… because cache was not being recreated between migrations
8fa5977
Contributor

darbula commented Mar 12, 2013

I have added one line because when testing on the new mysql database migrate was failing on rename_column. If it was restarted all went well. I tracked it down to the constraints cache not being updated so this one line forces cache update.

Contributor

darbula commented Mar 12, 2013

Thank you for considering credits update, Damir Arbula.

Owner

evildmp commented Mar 12, 2013

On the contrary, thank you for spotting and fixing the issue. Before I push your fixes, I also need to update the example database to reflect the new FKs.

evildmp merged commit 8fa5977 into evildmp:develop Mar 13, 2013

darbula deleted the unknown repository branch May 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment