def forwards(self, orm): db.rename_table('speeches_popolospeaker', 'speeches_speaker') db.alter_column('speeches_recordingtimestamp', 'speaker_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['speeches.Speaker'], null=True, on_delete=models.SET_NULL)) db.alter_column('speeches_speech', 'speaker_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['speeches.Speaker'], null=True, on_delete=models.SET_NULL)) if not db.dry_run: orm['contenttypes.contenttype'].objects.filter(app_label='speeches', model='speaker').update(model='oldspeaker') orm['contenttypes.contenttype'].objects.filter(app_label='speeches', model='popolospeaker').update(model='speaker')
def forwards(self, orm): # Renaming model 'CourseAttendance' db.rename_table(u'attendance_courseattendance', u'attendance_coursesectionattendance') if not db.dry_run: orm['contenttypes.contenttype'].objects.filter( app_label='attendance', model='courseattendance' ).update(model='coursesectionattendance')
def backwards(self, orm): # Adding model 'NavTree' #db.create_table('coop_cms_navtree', ( # ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), # ('name', self.gf('django.db.models.fields.CharField')(default='default', max_length=100, unique=True, db_index=True)), # ('last_update', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), #)) #db.send_create_signal('coop_cms', ['NavTree']) # ## Adding M2M table for field types on 'NavTree' #db.create_table('coop_cms_navtree_types', ( # ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), # ('navtree', models.ForeignKey(orm['coop_cms.navtree'], null=False)), # ('navtype', models.ForeignKey(orm['coop_cms.navtype'], null=False)) #)) #db.create_unique('coop_cms_navtree_types', ['navtree_id', 'navtype_id']) db.rename_table('basic_cms_navtree', 'coop_cms_navtree') # Removing M2M table for field types on 'NavTree' #db.delete_table('basic_cms_navtree_types') db.rename_table('basic_cms_navtree_types', 'coop_cms_navtree_types') # Changing field 'NavNode.tree' db.alter_column('coop_cms_navnode', 'tree_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['coop_cms.NavTree']))
def backwards(self, orm): # Renaming M2M table for field enquiries on 'Studentship' db.rename_table('vacancies_and_studentships_studentship_please_contact', 'vacancies_and_studentships_studentship_enquiries',) # Renaming M2M table for field enquiries on 'Vacancy' db.rename_table('vacancies_and_studentships_vacancy_please_contact', 'vacancies_and_studentships_vacancy_enquiries', )
def backwards(self, orm): # Removing unique constraint on 'Batch', fields ['project', 'name'] db.delete_unique('batch', ['project_id', 'name']) db.rename_table('batch', 'project_cohort') db.rename_column('sample', 'batch_id', 'cohort_id') # Changing field 'Sample.cohort' db.alter_column('sample', 'cohort_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['samples.Cohort'])) # Adding unique constraint on 'Cohort', fields ['project', 'name'] db.create_unique('project_cohort', ['project_id', 'name']) # Adding model 'CohortVariant' db.create_table('cohort_variant', ( ('cohort', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['samples.Cohort'])), ('variant', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['variants.Variant'])), ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('af', self.gf('django.db.models.fields.FloatField')(null=True, db_index=True)), )) db.send_create_signal('samples', ['CohortVariant']) # Adding unique constraint on 'CohortVariant', fields ['variant', 'cohort'] db.create_unique('cohort_variant', ['variant_id', 'cohort_id'])
def forwards(self, orm): # Deleting model 'Tag' db.rename_table('api_tag', 'tags_tag') # Adding model 'Domain' db.create_table('api_domain', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('name', self.gf('django.db.models.fields.CharField')(default='', max_length=100)), ('url', self.gf('django.db.models.fields.URLField')(max_length=300)), )) db.send_create_signal('api', ['Domain']) # Adding model 'Page' db.create_table('api_page', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('url', self.gf('django.db.models.fields.URLField')(max_length=300)), ('domain', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['api.Domain'])), ('title', self.gf('django.db.models.fields.CharField')(default='', max_length=2000)), ('favicon_url', self.gf('django.db.models.fields.TextField')(default='')), ('favIconUrl', self.gf('django.db.models.fields.URLField')(default='', max_length=2000)), ('description', self.gf('django.db.models.fields.TextField')(default='')), ('img_url', self.gf('django.db.models.fields.URLField')(default='', max_length=2000)), )) db.send_create_signal('api', ['Page']) # Adding field 'PopularHistoryInfo.page' db.add_column('api_popularhistoryinfo', 'page', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['api.Page'], null=True, on_delete=models.SET_NULL), keep_default=False) # Adding field 'EyeHistory.page' db.add_column('api_eyehistory', 'page', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['api.Page'], null=True, on_delete=models.SET_NULL), keep_default=False)
def forwards(self, orm): db.rename_table("text_text", "cmsplugin_text") db.rename_table("text_publictext", "cmsplugin_textpublic") db.alter_column('cmsplugin_text', 'public_id', orm['text.text:public']) db.drop_primary_key("cmsplugin_textpublic") db.rename_column("cmsplugin_textpublic", "publiccmsplugin_ptr_id", "cmspluginpublic_ptr_id") db.create_primary_key("cmsplugin_textpublic", ("cmspluginpublic_ptr_id",))
def backwards(self, orm): db.rename_table('billing_app_card', 'billing_app_stripecustomer') db.delete_unique('billing_app_stripecustomer', ['last4', 'tenant_id']) db.rename_column('billing_app_stripecustomer', 'last4', 'name') db.rename_column('billing_app_stripecustomer', 'default', 'is_default') db.create_unique('billing_app_stripecustomer', ['is_default', 'keystone_id']) db.delete_column('billing_app_stripecustomer', 'tenant_id')
def forwards(self, orm): db.rename_table('coop_cms_articlesection', 'coop_cms_articlecategory') ct = ContentType.objects.filter(app_label='coop_cms', model='articlesection') if ct.exists(): ct[0].model = 'articlecategory' ct[0].name = 'article category' ct[0].save()
def forwards(self, orm): db.rename_table("snippet_snippetptr", "cmsplugin_snippetptr") db.rename_table("snippet_publicsnippetptr", "cmsplugin_snippetptrpublic") db.alter_column('cmsplugin_snippetptr', 'public_id', orm['snippet.snippetptr:public']) #db.drop_primary_key("cmsplugin_snippetptrpublic") db.rename_column("cmsplugin_snippetptrpublic", "publiccmsplugin_ptr_id", "cmspluginpublic_ptr_id")
def forwards(self, orm): # Removing unique constraint on 'CohortVariant', fields ['variant', 'cohort'] db.delete_unique('cohort_variant', ['variant_id', 'cohort_id']) # Removing unique constraint on 'Cohort', fields ['project', 'name'] db.delete_unique('project_cohort', ['project_id', 'name']) # Removing unique constraint on 'Sample', fields ['cohort', 'name'] db.delete_unique('sample', ['cohort_id', 'name']) # Deleting model 'CohortVariant' db.delete_table('cohort_variant') # Renaming model 'Cohort' to 'Batch' db.rename_table('project_cohort', 'batch') # Adding unique constraint on 'Batch', fields ['project', 'name'] db.create_unique('batch', ['project_id', 'name']) # Changing field 'Sample.cohort' db.alter_column('sample', 'cohort_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['samples.Batch'])) db.rename_column('sample', 'cohort_id', 'batch_id') # Adding unique constraint on 'Sample', fields ['batch', 'name'] db.create_unique('sample', ['batch_id', 'name'])
def forwards(self, orm): # Adding M2M table for field coauthor on 'Alternative' m2m_table_name = db.shorten_name('dnstorm_alternative_coauthor') db.create_table(m2m_table_name, ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), ('alternative', models.ForeignKey(orm[u'app.alternative'], null=False)), ('user', models.ForeignKey(orm[u'auth.user'], null=False)) )) db.create_unique(m2m_table_name, ['alternative_id', 'user_id']) # Adding M2M table for field coauthor on 'Criteria' m2m_table_name = db.shorten_name('dnstorm_criteria_coauthor') db.create_table(m2m_table_name, ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), ('criteria', models.ForeignKey(orm[u'app.criteria'], null=False)), ('user', models.ForeignKey(orm[u'auth.user'], null=False)) )) db.create_unique(m2m_table_name, ['criteria_id', 'user_id']) # Adding M2M table for field coauthor on 'Idea' m2m_table_name = db.shorten_name('dnstorm_idea_coauthor') db.create_table(m2m_table_name, ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), ('idea', models.ForeignKey(orm[u'app.idea'], null=False)), ('user', models.ForeignKey(orm[u'auth.user'], null=False)) )) db.create_unique(m2m_table_name, ['idea_id', 'user_id']) # Removing M2M table for field contributor on 'Problem' db.rename_table('dnstorm_problem_contributor', 'dnstorm_problem_collaborator')
def forwards(self, orm): existing_tables = connection.introspection.table_names() # Adding model 'Message' if 'messages_message' in existing_tables: db.rename_table('messages_message', 'questions_message') else: db.create_table('questions_message', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('contest', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contests.Contest'], null=True, blank=True)), ('problem_instance', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contests.ProblemInstance'], null=True, blank=True)), ('problem', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['problems.Problem'], null=True, blank=True)), ('top_reference', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['questions.Message'], null=True, blank=True)), ('author', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('kind', self.gf('oioioi.base.fields.EnumField')(default='QUESTION', max_length=64)), ('topic', self.gf('django.db.models.fields.CharField')(max_length=255)), ('content', self.gf('django.db.models.fields.TextField')()), ('date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), )) db.send_create_signal('questions', ['Message']) # Adding model 'MessageView' if 'messages_messageview' in existing_tables: db.rename_table('messages_messageview', 'questions_messageview') else: db.create_table('questions_messageview', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('message', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['questions.Message'])), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), )) db.send_create_signal('questions', ['MessageView'])
def forwards(self, orm): # move some models from maps to layers app # 0. add some missing fields (not for wfp) db.start_transaction() try: # Adding field 'Layer.bbox_top' db.add_column('maps_layer', 'bbox_top', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False) # Adding field 'Layer.bbox_bottom' db.add_column('maps_layer', 'bbox_bottom', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False) # Adding field 'Layer.bbox_left' db.add_column('maps_layer', 'bbox_left', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False) # Adding field 'Layer.bbox_right' db.add_column('maps_layer', 'bbox_right', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False) db.commit_transaction() except: print 'No need to create the fields, they are already there' db.rollback_transaction() # 1. layers_layer moved from maps_layer db.rename_table('maps_layer', 'layers_layer') if not db.dry_run: orm['contenttypes.contenttype'].objects.filter(app_label='maps', model='layer').update(app_label='layers') # 2. layers_contactrole moved from maps_contactrole db.rename_table('maps_contactrole', 'layers_contactrole') if not db.dry_run: orm['contenttypes.contenttype'].objects.filter(app_label='maps', model='contactrole').update(app_label='layers')
def backwards(self, orm): # Adding M2M table for field speakers on 'Event' # db.create_table('news_and_events_event_speakers', ( # ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), # ('event', models.ForeignKey(orm['news_and_events.event'], null=False)), # ('person', models.ForeignKey(orm['contacts_and_people.person'], null=False)) # )) # db.create_unique('news_and_events_event_speakers', ['event_id', 'person_id']) db.rename_table("news_and_events_event_featuring", "news_and_events_event_speakers") # Adding M2M table for field registration_enquiries on 'Event' db.create_table( "news_and_events_event_registration_enquiries", ( ("id", models.AutoField(verbose_name="ID", primary_key=True, auto_created=True)), ("event", models.ForeignKey(orm["news_and_events.event"], null=False)), ("person", models.ForeignKey(orm["contacts_and_people.person"], null=False)), ), ) db.create_unique("news_and_events_event_registration_enquiries", ["event_id", "person_id"]) # Adding M2M table for field organisers on 'Event' db.create_table( "news_and_events_event_organisers", ( ("id", models.AutoField(verbose_name="ID", primary_key=True, auto_created=True)), ("event", models.ForeignKey(orm["news_and_events.event"], null=False)), ("person", models.ForeignKey(orm["contacts_and_people.person"], null=False)), ), ) db.create_unique("news_and_events_event_organisers", ["event_id", "person_id"])
def forwards(self, orm): db.rename_table('product_downloadableproduct', 'downloadable_downloadableproduct') # check if the table exists; might be a fresh, post 0.9 installation try: from django.db import connection cursor = connection.cursor() if not cursor: raise Exception table_names = connection.introspection.get_table_list(cursor) except: raise Exception("unable to determine if the table 'shop_downloadlink' exists") else: if not 'shop_downloadlink' in table_names: # create the table # create commands were obtained from a fresh --initial migration db.create_table('downloadable_downloadlink', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('downloadable_product', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['downloadable.DownloadableProduct'])), ('order', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['shop.Order'])), ('key', self.gf('django.db.models.fields.CharField')(max_length=40)), ('num_attempts', self.gf('django.db.models.fields.IntegerField')()), ('time_stamp', self.gf('django.db.models.fields.DateTimeField')()), ('active', self.gf('django.db.models.fields.BooleanField')(default=True)), )) db.send_create_signal('downloadable', ['DownloadLink']) else: db.rename_table('shop_downloadlink', 'downloadable_downloadlink')
def backwards(self, orm): db.rename_table( u'tasks_cronjob', u'system_cronjob', ) db.rename_table( u'tasks_initshutdown', u'system_initshutdown', ) db.rename_table( u'tasks_rsync', u'system_rsync', ) db.rename_table( u'tasks_smarttest', u'system_smarttest', ) db.rename_table( db.shorten_name(u'tasks_smarttest_smarttest_disks'), db.shorten_name(u'system_smarttest_smarttest_disks'), )
def forwards(self, orm): db.rename_table("flash_flash", "cmsplugin_flash") db.rename_table("flash_publicflash", "cmsplugin_flashpublic") db.alter_column('cmsplugin_flash', 'public_id', orm['flash.flash:public']) #db.drop_primary_key("cmsplugin_flashpublic") db.rename_column("cmsplugin_flashpublic", "publiccmsplugin_ptr_id", "cmspluginpublic_ptr_id")
def forwards(self, orm): table_names = connection.introspection.table_names() if 'cmsplugin_video' in table_names: db.rename_table('cmsplugin_video', 'djangocms_video_video') elif 'video_video' in table_names: db.rename_table('video_video', 'djangocms_video_video') else: # Adding model 'Video' db.create_table(u'djangocms_video_video', ( (u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)), ('movie', self.gf('django.db.models.fields.files.FileField')(max_length=100, null=True, blank=True)), ('movie_url', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), ('image', self.gf('django.db.models.fields.files.ImageField')(max_length=100, null=True, blank=True)), ('width', self.gf('django.db.models.fields.PositiveSmallIntegerField')()), ('height', self.gf('django.db.models.fields.PositiveSmallIntegerField')()), ('auto_play', self.gf('django.db.models.fields.BooleanField')(default=False)), ('auto_hide', self.gf('django.db.models.fields.BooleanField')(default=False)), ('fullscreen', self.gf('django.db.models.fields.BooleanField')(default=True)), ('loop', self.gf('django.db.models.fields.BooleanField')(default=False)), ('bgcolor', self.gf('django.db.models.fields.CharField')(default='000000', max_length=6)), ('textcolor', self.gf('django.db.models.fields.CharField')(default='FFFFFF', max_length=6)), ('seekbarcolor', self.gf('django.db.models.fields.CharField')(default='13ABEC', max_length=6)), ('seekbarbgcolor', self.gf('django.db.models.fields.CharField')(default='333333', max_length=6)), ('loadingbarcolor', self.gf('django.db.models.fields.CharField')(default='828282', max_length=6)), ('buttonoutcolor', self.gf('django.db.models.fields.CharField')(default='333333', max_length=6)), ('buttonovercolor', self.gf('django.db.models.fields.CharField')(default='000000', max_length=6)), ('buttonhighlightcolor', self.gf('django.db.models.fields.CharField')(default='FFFFFF', max_length=6)), )) db.send_create_signal(u'djangocms_video', ['Video'])
def backwards(self, orm): # Adding model 'RodzajMiejsowosci' # Rename model 'RodzajMiejscowosci' to 'RodzajMiejsowosci' db.rename_table('teryt_rodzajmiejscowosci', 'teryt_rodzajmiejsowosci') # Changing field 'Miejscowosc.rodzaj_miejscowosci' db.alter_column(u'teryt_miejscowosc', u'rodzaj_miejscowosci_id', self.gf(u'django.db.models.fields.related.ForeignKey')(to=orm['teryt.RodzajMiejsowosci']))
def forwards(self, orm): db.rename_table("fccpublicfiles_address", "locations_address") if not db.dry_run: # For permissions to work properly after migrating orm["contenttypes.contenttype"].objects.filter(app_label="fccpublicfiles", model="address").update( app_label="locations" )
def forwards(self, orm): # Deleting model 'BankAccount' db.delete_table('main_bankaccount') # Adding model 'MyBankAccount' db.create_table('main_mybankaccount', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('bank', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['main.Bank'])), ('accountowner', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('accountnum', self.gf('django.db.models.fields.FloatField')(unique=True)), ('routingnum', self.gf('django.db.models.fields.FloatField')()), )) db.send_create_signal('main', ['MyBankAccount']) # Adding model 'RecipientBankAccount' db.create_table('main_recipientbankaccount', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('bank', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['main.Bank'])), ('accountowner', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('accountnum', self.gf('django.db.models.fields.FloatField')(unique=True)), ('routingnum', self.gf('django.db.models.fields.FloatField')()), )) db.send_create_signal('main', ['RecipientBankAccount']) # Changing field 'Transaction.sender' db.alter_column('main_transaction', 'sender_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['main.MyBankAccount'])) # Changing field 'Transaction.receiver' db.alter_column('main_transaction', 'receiver_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['main.RecipientBankAccount'])) db.rename_table('main_bankaccount', 'main_mybankaccount')
def backwards(self, orm): db.drop_primary_key("cmsplugin_linkpublic") db.rename_column("cmsplugin_linkpublic", "cmspluginpublic_ptr_id", "publiccmsplugin_ptr_id") db.create_primary_key("cmsplugin_linkpublic", ("publiccmsplugin_ptr_id",)) db.rename_table("cmsplugin_link", "link_link") db.rename_table("cmsplugin_linkpublic", "link_publiclink") db.alter_column('cmsplugin_link', 'public_id', orm['link.link:public'])
def forwards(self, orm): db.rename_table('billing_app_stripecustomer', 'billing_app_card') db.delete_unique('billing_app_card', ['name', 'keystone_id']) db.rename_column('billing_app_card', 'name', 'last4') db.rename_column('billing_app_card', 'is_default', 'default') db.add_column('billing_app_card', 'tenant_id', models.fields.CharField(max_length=64, db_index=True)) db.create_unique('billing_app_card', ['last4', 'tenant_id'])
def forwards(self, orm): # These tables were already created by vera before we swapped out the # models db.rename_table('wq_event', 'data_event') return # Adding model 'Event' db.create_table('data_event', ( (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('site', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['locations.Site'], null=True, blank=True)), ('date', self.gf('django.db.models.fields.DateField')()), )) db.send_create_signal(u'data', ['Event']) # Adding unique constraint on 'Event', fields ['site', 'date'] db.create_unique('data_event', ['site_id', 'date']) # Adding model 'EventResult' db.create_table('wq_eventresult', ( ('id', self.gf('django.db.models.fields.PositiveIntegerField')(primary_key=True)), ('event', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['data.Event'])), ('result', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vera.Result'])), ('event_site', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['locations.Site'], null=True, blank=True)), ('event_date', self.gf('django.db.models.fields.DateField')()), ('result_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vera.Parameter'])), ('result_report', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vera.Report'])), ('result_value_numeric', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), ('result_value_text', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), ('result_empty', self.gf('django.db.models.fields.BooleanField')()), )) db.send_create_signal(u'data', ['EventResult']) # Adding unique constraint on 'EventResult', fields ['event', 'result_type'] db.create_unique('wq_eventresult', ['event_id', 'result_type_id'])
def forwards(self, orm): db.rename_table("googlemap_googlemap", "cmsplugin_googlemap") db.rename_table("googlemap_publicgooglemap", "cmsplugin_googlemappublic") db.alter_column('cmsplugin_googlemap', 'public_id', orm['googlemap.googlemap:public']) #db.drop_primary_key("cmsplugin_googlemappublic") db.rename_column("cmsplugin_googlemappublic", "publiccmsplugin_ptr_id", "cmspluginpublic_ptr_id")
def forwards(self, orm): # Deleting model 'Badge' db.rename_table(u'badge', u'askbot_badgedata') db.create_unique('askbot_badgedata', ['type', 'name']) # Changing field 'Award.badge' db.alter_column(u'award', 'badge_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['askbot.BadgeData']))
def forwards(self, orm): # Renaming model 'JobType' to model 'AbstractJobType' db.rename_table(u'my_ortoloco_jobtype', u'my_ortoloco_abstractjobtype') # Deleting field 'OneTimeJob.description' db.delete_column(u'my_ortoloco_onetimejob', 'description') # Deleting field 'OneTimeJob.name' db.delete_column(u'my_ortoloco_onetimejob', 'name') # Deleting field 'OneTimeJob.location' db.delete_column(u'my_ortoloco_onetimejob', 'location') # Deleting field 'OneTimeJob.duration' db.delete_column(u'my_ortoloco_onetimejob', 'duration') # Deleting field 'OneTimeJob.bereich' db.delete_column(u'my_ortoloco_onetimejob', 'bereich_id') # Deleting field 'OneTimeJob.displayed_name' db.delete_column(u'my_ortoloco_onetimejob', 'displayed_name') # Adding field 'OneTimeJob.abstractjobtype_ptr' db.add_column(u'my_ortoloco_onetimejob', u'abstractjobtype_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['my_ortoloco.AbstractJobType'], unique=True), keep_default=False) # Changing field 'RecuringJob.typ' db.alter_column(u'my_ortoloco_recuringjob', 'typ_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['my_ortoloco.AbstractJobType'], on_delete=models.PROTECT))
def forwards(self, orm): # Deleting field 'EventCluster.cluster_category' db.delete_column('cal_eventcluster', 'cluster_category_id') # Renaming M2M table for field cluster_categories on 'EventCluster' db.rename_table('cal_eventcluster_cluster_categories', 'cal_eventcluster_cluster_tags')
def forwards(self, orm): db.rename_table("picture_picture", "cmsplugin_picture") db.rename_table("picture_publicpicture", "cmsplugin_picturepublic") db.alter_column('cmsplugin_picture', 'public_id', orm['picture.picture:public']) #db.drop_primary_key("cmsplugin_picturepublic") db.rename_column("cmsplugin_picturepublic", "publiccmsplugin_ptr_id", "cmspluginpublic_ptr_id")
def forwards(self, orm): table_names = connection.introspection.table_names() if 'cmsplugin_flash' in table_names: db.rename_table('cmsplugin_flash', 'djangocms_flash_flash') elif 'flash_flash' in table_names: db.rename_table('flash_flash', 'djangocms_flash_flash') else: # Adding model 'Flash' db.create_table(u'djangocms_flash_flash', ( (u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')( to=orm['cms.CMSPlugin'], unique=True, primary_key=True)), ('file', self.gf('django.db.models.fields.files.FileField')( max_length=100)), ('width', self.gf('django.db.models.fields.CharField')(max_length=6)), ('height', self.gf('django.db.models.fields.CharField')(max_length=6)), )) db.send_create_signal(u'djangocms_flash', ['Flash'])
def forwards(self, orm): # Deleting model 'NotebookVisit' db.rename_table('cotizador_notebookvisit', 'cotizador_productvisit') # Deleting model 'NotebookComparisonList' db.rename_table('cotizador_notebookcomparisonlist', 'cotizador_productcomparisonlist') # Removing M2M table for field notebooks on 'NotebookComparisonList' db.rename_table('cotizador_notebookcomparisonlist_notebooks', 'cotizador_productcomparisonlist_notebooks') # Deleting model 'StoreNotebookHistory' db.rename_table('cotizador_storenotebookhistory', 'cotizador_storeproducthistory')
def test_table_rename(self): """ Test column renaming """ cursor = connection.cursor() db.create_table("testtr", [('spam', models.BooleanField(default=False))]) db.start_transaction() # Make sure we can select the column cursor.execute("SELECT spam FROM testtr") # Rename it db.rename_table("testtr", "testtr2") cursor.execute("SELECT spam FROM testtr2") try: cursor.execute("SELECT spam FROM testtr") self.fail("Just-renamed column could be selected!") except: pass db.rollback_transaction() db.delete_table("testtr2")
def forwards(self, orm): # Removing unique constraint on 'OwnerComment', fields ['booking'] db.delete_unique(u'rent_ownercomment', ['booking_id']) # Changing field 'OwnerComment.booking' db.alter_column( u'rent_ownercomment', 'booking_id', self.gf('django.db.models.fields.related.ForeignKey')( to=orm['rent.Booking'])) # Renaming model 'OwnerComment' to 'Comment' db.rename_table('rent_ownercomment', 'rent_comment') # Adding field 'Comment.type' db.add_column( u'rent_comment', 'type', self.gf('django.db.models.fields.PositiveSmallIntegerField')( default=0, db_index=True), keep_default=False)
def test_renamed_referenced_table(self): """Rename a table referred to in a foreign key""" if db.backend_name != "mysql": return main_table = 'test_rn_refd_table' ref_table = 'test_rrt_ref' renamed_table = 'test_renamed_ref' self._create_foreign_tables(main_table, ref_table) db.execute_deferred_sql() constraints = db._lookup_reverse_constraint(ref_table) self.assertEquals(len(constraints), 1) db.rename_table(ref_table, renamed_table) db.execute_deferred_sql() #Create constraints constraints = db._find_foreign_constraints(main_table, 'foreign_id') self.assertEquals(len(constraints), 1) (rtable, rcolumn) = db._lookup_constraint_references(main_table, constraints[0]) self.assertEquals(renamed_table, rtable) db.delete_table(main_table) db.delete_table(renamed_table)
def forwards(self, orm): """ This migration has been customized to support upgrades from Cloudera Enterprise 3.5, as well as Hue 1.2 """ try: db.rename_table('userman_ldapgroup', 'useradmin_ldapgroup') db.delete_column('useradmin_ldapgroup', 'hidden') except Exception, e: db.rollback_transaction() db.start_transaction() # Adding model 'LdapGroup' db.create_table('useradmin_ldapgroup', ( ('group', self.gf('django.db.models.fields.related.ForeignKey')( related_name='group', to=orm['auth.Group'])), ('id', self.gf('django.db.models.fields.AutoField')( primary_key=True)), )) db.send_create_signal('useradmin', ['LdapGroup'])
def test_rename_constrained_table(self): """Renames a table with a foreign key column (towards another table)""" if db.backend_name != "mysql": return main_table = 'test_rn_table' ref_table = 'test_rt_ref' renamed_table = 'test_renamed_table' self._create_foreign_tables(main_table, ref_table) db.execute_deferred_sql() constraints = db._find_foreign_constraints(main_table, 'foreign_id') self.assertEquals(len(constraints), 1) db.rename_table(main_table, renamed_table) db.execute_deferred_sql() #Create constraints constraints = db._find_foreign_constraints(renamed_table, 'foreign_id') self.assertEquals(len(constraints), 1) (rtable, rcolumn) = db._lookup_constraint_references(renamed_table, constraints[0]) self.assertEquals(rcolumn, 'id') db.delete_table(renamed_table) db.delete_table(ref_table)
def forwards(self, orm): if HAS_CONFIGVAL: # and not HAS_SERVERCONF: # this means we have to rename the old one db.rename_table("config_configvalue", "server_serverconfig") for conf in orm.ServerConfig.objects.all(): conf.db_value = pickle.dumps(conf.db_value) conf.save() else: # not HAS_SERVERCONF: # this will happen if we start db from scratch (the config # app will then already be gone and no data is to be transferred) # So instead of renaming the old we instead have to manually create the new model. # Adding model 'ServerConfig' db.create_table('server_serverconfig', ( ('id', self.gf('django.db.models.fields.AutoField')( primary_key=True)), ('db_key', self.gf('django.db.models.fields.CharField')( unique=True, max_length=64)), ('db_value', self.gf('django.db.models.fields.TextField')(blank=True)), )) db.send_create_signal('server', ['ServerConfig'])
def backwards(self, orm): db.rename_table('accounts_timtecuser', 'core_timtecuser') db.rename_table(db.shorten_name(u'accounts_timtecuser_groups'), db.shorten_name(u'core_timtecuser_groups')) db.rename_table( db.shorten_name(u'accounts_timtecuser_user_permissions'), db.shorten_name(u'core_timtecuser_user_permissions'))
def forwards(self, orm): db.rename_table('product_downloadableproduct', 'downloadable_downloadableproduct') # check if the table exists; might be a fresh, post 0.9 installation try: from django.db import connection cursor = connection.cursor() if not cursor: raise Exception table_names = connection.introspection.get_table_list(cursor) except: raise Exception( "unable to determine if the table 'shop_downloadlink' exists") else: if not 'shop_downloadlink' in table_names: # create the table # create commands were obtained from a fresh --initial migration db.create_table('downloadable_downloadlink', ( ('id', self.gf('django.db.models.fields.AutoField')( primary_key=True)), ('downloadable_product', self.gf('django.db.models.fields.related.ForeignKey')( to=orm['downloadable.DownloadableProduct'])), ('order', self.gf('django.db.models.fields.related.ForeignKey')( to=orm['shop.Order'])), ('key', self.gf('django.db.models.fields.CharField')( max_length=40)), ('num_attempts', self.gf('django.db.models.fields.IntegerField')()), ('time_stamp', self.gf('django.db.models.fields.DateTimeField')()), ('active', self.gf('django.db.models.fields.BooleanField')( default=True)), )) db.send_create_signal('downloadable', ['DownloadLink']) else: db.rename_table('shop_downloadlink', 'downloadable_downloadlink')
def forwards(self, orm): # Adding model 'UserProfile' db.create_table(u'user_userprofile', ( (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('user', self.gf('django.db.models.fields.related.OneToOneField')( related_name='profile', unique=True, to=orm['auth.User'])), ('avatar', self.gf('django.db.models.fields.CharField')(max_length=255)), )) db.send_create_signal(u'user', ['UserProfile']) if u'auth_user' not in connection.introspection.table_names(): for user in orm['user.User'].objects.all(): # Can't use get_or_create() here because sqlite doesn't support # atomic transactions try: user_profile = orm.UserProfile.objects.get(user_id=user.id) except orm.UserProfile.DoesNotExist: user_profile = orm.UserProfile.objects.create( user_id=user.id) user_profile.avatar = user.avatar user_profile.save() db.rename_table(u'user_user', u'auth_user') db.rename_table(u'user_user_groups', u'auth_user_groups') db.rename_table(u'user_user_user_permissions', u'auth_user_user_permissions') db.delete_column(u'auth_user', u'avatar'), else: db.delete_table(u'user_user') db.delete_table(u'user_user_groups') db.delete_table(u'user_user_user_permissions')
def forwards(self, orm): # Adding M2M table for field coauthor on 'Alternative' m2m_table_name = db.shorten_name('dnstorm_alternative_coauthor') db.create_table( m2m_table_name, (('id', models.AutoField( verbose_name='ID', primary_key=True, auto_created=True)), ('alternative', models.ForeignKey(orm[u'app.alternative'], null=False)), ('user', models.ForeignKey(orm[u'auth.user'], null=False)))) db.create_unique(m2m_table_name, ['alternative_id', 'user_id']) # Adding M2M table for field coauthor on 'Criteria' m2m_table_name = db.shorten_name('dnstorm_criteria_coauthor') db.create_table( m2m_table_name, (('id', models.AutoField( verbose_name='ID', primary_key=True, auto_created=True)), ('criteria', models.ForeignKey(orm[u'app.criteria'], null=False)), ('user', models.ForeignKey(orm[u'auth.user'], null=False)))) db.create_unique(m2m_table_name, ['criteria_id', 'user_id']) # Adding M2M table for field coauthor on 'Idea' m2m_table_name = db.shorten_name('dnstorm_idea_coauthor') db.create_table( m2m_table_name, (('id', models.AutoField( verbose_name='ID', primary_key=True, auto_created=True)), ('idea', models.ForeignKey(orm[u'app.idea'], null=False)), ('user', models.ForeignKey(orm[u'auth.user'], null=False)))) db.create_unique(m2m_table_name, ['idea_id', 'user_id']) # Removing M2M table for field contributor on 'Problem' db.rename_table('dnstorm_problem_contributor', 'dnstorm_problem_collaborator')
def backwards(self, orm): # Adding model 'TrainingSchedule' db.rename_table('manager_workout', 'manager_trainingschedule') db.send_create_signal('manager', ['TrainingSchedule']) if not db.dry_run: content_type = orm['contenttypes.ContentType']() content_type.name = 'workout log' content_type.app_label = 'manager' content_type.model = 'trainingschedule' content_type.save() # Changing field 'WorkoutLog.workout' db.alter_column( 'manager_workoutlog', 'workout_id', self.gf('django.db.models.fields.related.ForeignKey')( to=orm['manager.TrainingSchedule'])) # Changing field 'Day.training' db.alter_column( 'manager_day', 'training_id', self.gf('django.db.models.fields.related.ForeignKey')( to=orm['manager.TrainingSchedule']))
def backwards(self, orm): "Write your backwards migration here" db.rename_table('localtv_feed_auto_authors', 'localtv_feed_auto_authors_user') db.rename_table('localtv_video_authors', 'localtv_video_authors_user') db.rename_table('localtv_sitelocation_admins', 'localtv_sitelocation_admins_user')
def forwards(self, orm): table_names = connection.introspection.table_names() if 'snippet_snippet' in table_names or 'cmsplugin_snippetptr' in table_names: if 'cmsplugin_snippetptr' in table_names: db.rename_table('cmsplugin_snippetptr', 'djangocms_snippet_snippetptr') if 'snippet_snippet' in table_names: db.rename_table('snippet_snippet', 'djangocms_snippet_snippet') else: # Adding model 'Snippet' db.create_table(u'djangocms_snippet_snippet', ( (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)), ('html', self.gf('django.db.models.fields.TextField')(blank=True)), ('template', self.gf('django.db.models.fields.CharField')(max_length=50, blank=True)), )) db.send_create_signal(u'djangocms_snippet', ['Snippet']) # Adding model 'SnippetPtr' db.create_table(u'djangocms_snippet_snippetptr', ( (u'cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)), ('snippet', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djangocms_snippet.Snippet'])), )) db.send_create_signal(u'djangocms_snippet', ['SnippetPtr'])
def backwards(self, orm): for old_appname, new_appname in self.apps_to_rename.items(): # Renaming model from 'Foo' to 'Bar' db.execute( "UPDATE south_migrationhistory SET app_name = %s WHERE app_name = %s", [old_appname, new_appname]) db.execute( "UPDATE django_content_type SET app_label = %s WHERE app_label = %s", [old_appname, new_appname]) app = get_app(new_appname) for model in get_models(app, include_auto_created=True): if model._meta.proxy == True or ( hasattr(model, 'connection_name') and model.connection_name == 'udd'): continue old_table_name = model._meta.db_table model_name = old_table_name.split('_')[1] new_table_name = ''.join([new_appname, '_', model_name]) db.rename_table(old_table_name, new_table_name)
def forwards(self, orm): db.rename_table('tardis_portal_dataset_file', 'tardis_portal_datafile') db.send_create_signal('tardis_portal', ['DataFile']) # db.rename_column('tardis_portal_datafileparameterset', 'dataset_file', # 'datafile') db.rename_column('tardis_portal_datafileparameterset', 'dataset_file_id', 'datafile_id') # db.alter_column('tardis_portal_datafileparameterset', 'datafile', # self.gf('django.db.models.fields.related.ForeignKey')( # to=orm['tardis_portal.DataFile'] # )) if not db.dry_run: # For permissions to work properly after migrating orm['contenttypes.contenttype'].objects.filter( app_label='tardis_portal', model='dataset_file').update(model='datafile') # cleaning up from 0022-0024. should not affect anyone # as the relevant data has been transferred, just a stale # content_type left over and permissions haven't been used by # anyone for ACL changes AFAIK orm['contenttypes.contenttype'].objects.filter( app_label='tardis_portal', model='experimentacl').delete()
def forwards(self, orm): db.delete_unique('product_discount_sites', ['discount_id', 'site_id']) db.rename_table('product_discount_sites', 'product_discount_site') db.create_unique('product_discount_site', ['discount_id', 'site_id']) db.delete_unique('product_category_sites', ['category_id', 'site_id']) db.rename_table('product_category_sites', 'product_category_site') db.create_unique('product_category_site', ['category_id', 'site_id']) db.delete_unique('product_optiongroup_sites', ['optiongroup_id', 'site_id']) db.rename_table('product_optiongroup_sites', 'product_optiongroup_site') db.create_unique('product_optiongroup_site', ['optiongroup_id', 'site_id']) db.delete_unique('product_product_sites', ['product_id', 'site_id']) db.rename_table('product_product_sites', 'product_product_site') db.create_unique('product_product_site', ['product_id', 'site_id'])
def forwards(self, orm): # Rename model 'Category' to 'Tag' db.rename_table(u'assets_category', u'assets_tag') db.execute( "ALTER INDEX assets_category_pkey RENAME TO assets_tag_pkey") db.execute( "ALTER INDEX assets_category_store_id RENAME TO assets_tag_store_id" ) # Rename M2M table for field products on 'Category' db.delete_unique('assets_category_products', ['category_id', 'product_id']) db.rename_table(db.shorten_name(u'assets_category_products'), db.shorten_name(u'assets_tag_products')) db.rename_column(db.shorten_name(u'assets_tag_products'), 'category_id', 'tag_id') db.execute( "ALTER INDEX assets_category_products_pkey RENAME TO assets_tag_products_pkey" ) db.execute( "ALTER INDEX assets_category_products_category_id RENAME TO assets_tag_products_tag_id" ) db.execute( "ALTER INDEX assets_category_products_product_id RENAME TO assets_tag_products_product_id" ) db.create_unique('assets_tag_products', ['tag_id', 'product_id']) # Rename model in the contenttypes table if not db.dry_run: orm['contenttypes.contenttype'].objects.filter( app_label='assets', model='category').update(model='tag') # Changing field 'Page.feed' db.alter_column( u'assets_page', 'feed_id', self.gf('django.db.models.fields.related.ForeignKey')( null=True, to=orm['assets.Feed']))
def forwards(self, orm): db.rename_table("cms_publicpage", "cms_pagepublic") # db.delete_unique('cms_publictitle', ['language', 'page_id']) db.rename_table("cms_publictitle", "cms_titlepublic") db.rename_table("cms_publiccmsplugin", "cms_cmspluginpublic") db.alter_column('cms_cmsplugin', 'inherited_public_id', orm['cms.cmsplugin:inherited_public']) db.alter_column('cms_title', 'public_id', orm['cms.title:public']) db.alter_column('cms_page', 'public_id', orm['cms.page:public'])
def forwards(self, orm): # Adding model 'ExternalChannelConnection' db.create_table('comms_externalchannelconnection', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('db_channel', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['comms.Channel'])), ('db_external_key', self.gf('django.db.models.fields.CharField')(max_length=128)), ('db_external_path', self.gf('django.db.models.fields.CharField')(max_length=128)), ('db_external_config', self.gf('django.db.models.fields.TextField')(blank=True)), ('db_is_enabled', self.gf('django.db.models.fields.BooleanField')(default=True)), )) db.send_create_signal('comms', ['ExternalChannelConnection']) db.rename_table('comms_channelconnection', 'comms_playerchannelconnection') # # Adding model 'PlayerChannelConnection' # db.create_table('comms_playerchannelconnection', ( # ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), # ('db_player', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['players.PlayerDB'])), # ('db_channel', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['comms.Channel'])), # )) # db.send_create_signal('comms', ['PlayerChannelConnection']) # # move channelconnections to playerchannelconnections # for conn in orm.ChannelConnection.objects.all(): # ncon = orm.PlayerChannelConnection(db_player=conn.db_player, db_channel=conn.db_channel) # ncon.save() # db # # Deleting model 'ChannelConnection' # db.delete_table('comms_channelconnection') # Adding field 'Msg.db_sender_external' db.add_column('comms_msg', 'db_sender_external', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True), keep_default=False) # Changing field 'Msg.db_sender' db.alter_column('comms_msg', 'db_sender_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['players.PlayerDB']))
def forwards(self, orm): # Renaming/Creating model 'ARmessage' if db_table_exists('main_armessage'): db.rename_table('main_armessage', 'postfix_autoreply_armessage') else: db.create_table( 'postfix_autoreply_armessage', (('mbox', self.gf('django.db.models.fields.related.ForeignKey')( to=orm['admin.Mailbox'])), ('id', self.gf('django.db.models.fields.AutoField')( primary_key=True)), ('subject', self.gf('django.db.models.fields.CharField')( max_length=255)), ('content', self.gf('django.db.models.fields.TextField')()), ('enabled', self.gf('django.db.models.fields.BooleanField')( default=False, blank=True)))) db.send_create_signal('postfix_autoreply', ['ARmessage']) db.add_column('postfix_autoreply_armessage', 'untildate', models.DateTimeField(null=True)) # Renaming model 'ARhistoric' if db_table_exists('main_arhistoric'): db.rename_table('main_arhistoric', 'postfix_autoreply_arhistoric') else: db.create_table('postfix_autoreply_arhistoric', ( ('armessage', self.gf('django.db.models.fields.related.ForeignKey')( to=orm['postfix_autoreply.ARmessage'])), ('id', self.gf('django.db.models.fields.AutoField')( primary_key=True)), ('last_sent', self.gf('django.db.models.fields.DateTimeField')( auto_now=True)), ('sender', self.gf('django.db.models.fields.TextField')()), )) db.send_create_signal('postfix_autoreply', ['ARhistoric'])
def backwards(self, orm): # # Adding model 'ChannelConnection' # db.create_table('comms_channelconnection', ( # ('db_channel', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['comms.Channel'])), # ('db_player', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['players.PlayerDB'])), # ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), # )) # db.send_create_signal('comms', ['ChannelConnection']) # db.rename_table('comms_playerchannelconnection', 'comms_channelconnection') # Deleting model 'ExternalChannelConnection' db.delete_table('comms_externalchannelconnection') # # Deleting model 'PlayerChannelConnection' # db.delete_table('comms_playerchannelconnection') # Deleting field 'Msg.db_sender_external' db.delete_column('comms_msg', 'db_sender_external') # User chose to not deal with backwards NULL issues for 'Msg.db_sender' raise RuntimeError("Cannot reverse this migration. 'Msg.db_sender' and its values cannot be restored.")
def forwards(self, orm): using_mysql = db.backend_name == 'mysql' db.rename_table('easy_thumbnails_storagenew', 'easy_thumbnails_storage') if using_mysql: try: db.drop_foreign_key('easy_thumbnails_source', 'storage_new_id') except ValueError: e = sys.exc_info()[1] # Python 2.5 compatable "as e" # e.g MyISAM tables don't support foreign key constraints print("Could not remove foreign key contraint: %s" % e) db.rename_column('easy_thumbnails_source', 'storage_new_id', 'storage_id') if using_mysql: try: db.execute('ALTER TABLE easy_thumbnails_source ADD CONSTRAINT ' 'sourcestorage_id_fk_to_storage FOREIGN KEY (storage_id) ' 'REFERENCES easy_thumbnails_storage(id)') except Exception: e = sys.exc_info()[1] # Python 2.5 compatable "as e" print("Could not add contraint: %s" % e) if using_mysql: try: db.drop_foreign_key('easy_thumbnails_thumbnail', 'storage_new_id') except ValueError: e = sys.exc_info()[1] # Python 2.5 compatable "as e" # e.g MyISAM tables don't support foreign key constraints print("Could not remove foreign key contraint: %s" % e) db.rename_column('easy_thumbnails_thumbnail', 'storage_new_id', 'storage_id') if using_mysql: try: db.execute('ALTER TABLE easy_thumbnails_thumbnail ADD CONSTRAINT ' 'thumbnailstorage_id_fk_to_storage FOREIGN KEY (storage_id) ' 'REFERENCES easy_thumbnails_storage(id)') except Exception: e = sys.exc_info()[1] # Python 2.5 compatable "as e" print("Could not add contraint: %s" % e)
def backwards(self, orm): db.rename_table('cotizador_storehasnotebookentity', 'cotizador_storehasnotebook') # Changing field 'LogLostModel.shn' db.alter_column('cotizador_loglostmodel', 'shn_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cotizador.StoreHasNotebook'])) # Changing field 'LogNewModel.shn' db.alter_column('cotizador_lognewmodel', 'shn_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cotizador.StoreHasNotebook'])) # Changing field 'Notebook.publicized_offer' db.alter_column('cotizador_notebook', 'publicized_offer_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['cotizador.StoreHasNotebook'])) # Changing field 'LogReviveModel.shn' db.alter_column('cotizador_logrevivemodel', 'shn_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cotizador.StoreHasNotebook'])) # Changing field 'LogChangeModelPrice.shn' db.alter_column('cotizador_logchangemodelprice', 'shn_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cotizador.StoreHasNotebook'])) # Changing field 'ExternalVisit.shn' db.alter_column('cotizador_externalvisit', 'shn_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cotizador.StoreHasNotebook'])) # Changing field 'StoreNotebookHistory.registry' db.alter_column('cotizador_storenotebookhistory', 'registry_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cotizador.StoreHasNotebook']))
def forwards(self, orm): try: # Check if front exists db.execute('select * from front_person limit 1') models = ['person', 'orggroup', 'wikihighlight', 'alert', 'officelocation'] for model in models: # Delete core tables if they exist try: db.delete_table('core_' + model) except: pass db.rename_table('front_' + model, 'core_' + model) if not db.dry_run: orm['contenttypes.ContentType'].objects.filter( app_label='core').delete() orm['contenttypes.ContentType'].objects.filter( app_label='front').update(app_label='core') except DatabaseError: pass
def forwards(self, orm): if "auth_user" not in connection.introspection.table_names(): # Fresh installations of Pootle will not have an auth_user table. db.create_table("accounts_user", ( (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('password', self.gf('django.db.models.fields.CharField')(max_length=128)), ('last_login', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)), ('username', self.gf('django.db.models.fields.CharField')(unique=True, max_length=30)), ('email', self.gf('django.db.models.fields.EmailField')(max_length=255)), ('full_name', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)), ('is_active', self.gf('django.db.models.fields.BooleanField')(default=True)), ('is_superuser', self.gf('django.db.models.fields.BooleanField')(default=False)), ('date_joined', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)), )) db.send_create_signal("accounts", ["User"]) # We're done here return # We now have a full_name column instead of first_name and last_name db.add_column("auth_user", "full_name", self.gf("django.db.models.fields.CharField")(default='', max_length=255), keep_default=False) if db.backend_name == "mysql": db.execute("UPDATE auth_user SET full_name = CONCAT(`first_name`, ' ', `last_name`)") else: # Works in postgres and sqlite db.execute("UPDATE auth_user SET full_name = first_name || ' ' || last_name") # Delete the first_name and last_name columns now db.delete_column("auth_user", "first_name") db.delete_column("auth_user", "last_name") # We don't use the is_staff column either db.delete_column("auth_user", "is_staff") # Finally, rename the table to accounts_user db.rename_table("auth_user", "accounts_user")
def forwards(self, orm): db.rename_table('players_playerdbtmp', 'players_playerdb') db.rename_table('players_playerdbtmp_groups', 'players_playerdb_groups') db.rename_column('players_playerdb_groups', 'playerdbtmp_id', 'playerdb_id') db.rename_table('players_playerdbtmp_user_permissions', 'players_playerdb_user_permissions') db.rename_column('players_playerdb_user_permissions', 'playerdbtmp_id', 'playerdb_id')
def backwards(self, orm): "Write your backwards methods here." db.rename_column('comms_channeldb_db_attributes', 'channeldb_id', 'interimchannel_id') db.rename_column('comms_channeldb_db_tags', 'channeldb_id', 'interimchannel_id') db.rename_table('comms_channeldb', 'comms_interimchannel') db.rename_table('comms_channeldb_db_attributes', 'comms_interimchannel_db_attributes') db.rename_table('comms_channeldb_db_tags', 'comms_interimchannel_db_tags')
def backwards(self, orm): db.rename_column('common_subscription_exclude', 'subscription_id', 'userset_id') db.rename_column('common_subscription_groups', 'subscription_id', 'userset_id') db.rename_column('common_deadline', 'subscription_id', 'userset_id') db.rename_table('common_subscription_exclude', 'common_userset_exclude') db.rename_table('common_subscription_groups', 'common_userset_groups') db.rename_table('common_subscription', 'common_userset')