Lose data with django-south schemamigration -


i have django model around 500k entries in mysql database. i'd add field model:

site = models.foreignkey(site, verbose_name=_('site'),null=true,blank=true). 

but lose data, running:

python manage.py schemamigration product --auto python manage.py migrate product 

the migration script generated is:

class migration(schemamigration):     def forwards(self, orm):         # adding field 'product.site'         db.add_column('product_product', 'site',                       self.gf('django.db.models.fields.related.foreignkey')(to=orm['sites.site'], null=true, blank=true),                       keep_default=false)     def backwards(self, orm):         # deleting field 'product.site'         db.delete_column('product_product', 'site_id') 

the sql generated migration is:

running migrations product:  - migrating forwards 0016_auto__add_field_product_site.  > product:0016_auto__add_field_product_site    = set foreign_key_checks=0; []    = alter table `product_product` add column `site_id` integer null; []    - no dry run output alter_column() due dynamic ddl, sorry    = alter table `product_product` add constraint `site_id_refs_id_10570b8a766fecf5` foreign key (`site_id`) references `django_site` (`id`); []    = create index `product_product_6223029` on `product_product` (`site_id`); [] 

the latest migration history 'python manager.py migrate product--list' is:

(*) 0011_auto__add_field_product_category_str (*) 0012_auto__add_field_product_store_id (*) 0013_auto__del_field_product_site__del_unique_product_sku_site__del_unique_ (*) 0014_auto__chg_field_product_short_description__chg_field_product_descripti (*) 0015_auto__add_field_product_phase_tag ( ) 0016_auto__add_field_product_site 

fortunately, have database backup. there way add field model without losing existing data?

with 500k records, might not possible situation, benefit of others might coming page, might want try using django-evolution https://code.google.com/p/django-evolution/ instead of south. have used both , have found while less full-featured, evolution handles migrations far less fuss south.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -