本文整理汇总了Python中south.db.db.delete_foreign_key函数的典型用法代码示例。如果您正苦于以下问题:Python delete_foreign_key函数的具体用法?Python delete_foreign_key怎么用?Python delete_foreign_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_foreign_key函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: forwards
def forwards(self, orm):
# It's not a foreign key anymore, it's just a primary key field
db.delete_foreign_key('pagelets_pagelet', 'pageletbase_ptr_id')
db.alter_column('pagelets_pagelet', 'pageletbase_ptr_id', self.gf('django.db.models.fields.IntegerField')())
# Renaming field 'Pagelet.pageletbase_ptr' to 'id'
db.rename_column('pagelets_pagelet', 'pageletbase_ptr_id', 'id')
# Adding field 'Pagelet.creation_date'
db.add_column('pagelets_pagelet', 'creation_date', self.gf('django.db.models.fields.DateTimeField')(null=True), keep_default=False)
# Adding field 'Pagelet.created_by'
db.add_column('pagelets_pagelet', 'created_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='pagelets_pagelet_created', null=True, to=orm[user_orm_label]), keep_default=False)
# Adding field 'Pagelet.last_changed'
db.add_column('pagelets_pagelet', 'last_changed', self.gf('django.db.models.fields.DateTimeField')(null=True), keep_default=False)
# Adding field 'Pagelet.modified_by'
db.add_column('pagelets_pagelet', 'modified_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='pagelets_pagelet_last_modified', null=True, to=orm[user_orm_label]), keep_default=False)
# Renaming field 'Page.pageletbase_ptr' to 'id'
db.rename_column('pagelets_page', 'pageletbase_ptr_id', 'id')
# Adding field 'Page.creation_date'
db.add_column('pagelets_page', 'creation_date', self.gf('django.db.models.fields.DateTimeField')(null=True), keep_default=False)
# Adding field 'Page.created_by'
db.add_column('pagelets_page', 'created_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='pagelets_page_created', null=True, to=orm[user_orm_label]), keep_default=False)
# Adding field 'Page.last_changed'
db.add_column('pagelets_page', 'last_changed', self.gf('django.db.models.fields.DateTimeField')(null=True), keep_default=False)
# Adding field 'Page.modified_by'
db.add_column('pagelets_page', 'modified_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='pagelets_page_last_modified', null=True, to=orm[user_orm_label]), keep_default=False)
示例2: forwards
def forwards(self, orm):
# Deleting field 'MessageLog.parent_id'
#db.delete_foreign_key('message_log_messagelog', 'parent_id_id')
db.delete_column('message_log_messagelog', 'parent_id_id')
# Deleting field 'MessageLog.revision_after'
db.delete_foreign_key('message_log_messagelog', 'revision_after_id')
db.delete_column('message_log_messagelog', 'revision_after_id')
# Deleting field 'MessageLog.revision_before'
db.delete_foreign_key('message_log_messagelog', 'revision_before_id')
db.delete_column('message_log_messagelog', 'revision_before_id')
# Adding field 'MessageLog.revision'
db.add_column('message_log_messagelog', 'revision', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['reversion.Revision'], null=True, blank=True), keep_default=False)
# Adding field 'MessageLog.uuid'
db.add_column('message_log_messagelog', 'uuid', self.gf('django.db.models.fields.CharField')(default='', max_length=36, db_index=True), keep_default=False)
# Adding field 'MessageLog.parent_uuid'
db.add_column('message_log_messagelog', 'parent_uuid', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=36, null=True, blank=True), keep_default=False)
# Adding field 'MessageLog.group_uuid'
db.add_column('message_log_messagelog', 'group_uuid', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=36, null=True, blank=True), keep_default=False)
示例3: backwards
def backwards(self, orm):
db.delete_foreign_key('cmsplugin_flash' ,'public_id')
db.drop_primary_key("cmsplugin_flashpublic")
db.rename_column("cmsplugin_flashpublic", "cmspluginpublic_ptr_id", "publiccmsplugin_ptr_id")
db.create_primary_key("cmsplugin_flashpublic", ("publiccmsplugin_ptr_id",))
db.rename_table("cmsplugin_flash", "flash_flash")
db.rename_table("cmsplugin_flashpublic", "flash_publicflash")
db.alter_column('cmsplugin_flash', 'public_id', orm['flash.flash:public'])
示例4: forwards
def forwards(self, orm):
db.delete_foreign_key('fccpublicfiles_politicalbuy', 'publicdocument_ptr_id')
db.rename_column('fccpublicfiles_politicalbuy', 'publicdocument_ptr_id', 'id')
db.execute_many('''
create sequence fccpublicfiles_politicalbuy_id_seq;
select setval('fccpublicfiles_politicalbuy_id_seq', max(id)) from fccpublicfiles_publicdocument;
alter table fccpublicfiles_politicalbuy alter column id set default nextval('fccpublicfiles_politicalbuy_id_seq');
''')
示例5: backwards
def backwards(self, orm):
db.delete_foreign_key("cmsplugin_file", "public_id")
db.drop_primary_key("cmsplugin_filepublic")
db.rename_column("cmsplugin_filepublic", "cmspluginpublic_ptr_id", "publiccmsplugin_ptr_id")
db.create_primary_key("cmsplugin_filepublic", ("publiccmsplugin_ptr_id",))
db.rename_table("cmsplugin_file", "file_file")
db.rename_table("cmsplugin_filepublic", "file_publicfile")
db.alter_column("cmsplugin_file", "public_id", orm["file.file:public"])
示例6: clean_constraints
def clean_constraints(t1, c1, t2, c2):
# Workaround for http://south.aeracode.org/ticket/775
if db.backend_name != "sqlite3":
try:
db.delete_foreign_key(t1, c1)
db.execute(db.foreign_key_sql(t1, c1, t2, c2))
except ValueError as e:
print("Warning: Could not clean up constraints (this may be harmless): %s" % (e))
示例7: backwards
def backwards(self, orm):
db.delete_foreign_key('cmsplugin_text' ,'public_id')
db.drop_primary_key("cmsplugin_textpublic")
db.rename_column("cmsplugin_textpublic", "cmspluginpublic_ptr_id", "publiccmsplugin_ptr_id")
db.create_primary_key("cmsplugin_textpublic", ("publiccmsplugin_ptr_id",))
db.foreign_key_sql('cmsplugin_text' ,'public_id', 'cmsplugin_textpublic', "publiccmsplugin_ptr_id")
db.rename_table("cmsplugin_text", "text_text")
db.rename_table("cmsplugin_textpublic", "text_publictext")
db.alter_column('cmsplugin_text', 'public_id', orm['text.text:public'])
示例8: backwards
def backwards(self, orm):
try:
db.delete_foreign_key('cmsplugin_file' ,'public_id')
except:
pass
db.drop_primary_key("cmsplugin_filepublic")
db.rename_column("cmsplugin_filepublic", "cmspluginpublic_ptr_id", "publiccmsplugin_ptr_id")
db.create_primary_key("cmsplugin_filepublic", ("publiccmsplugin_ptr_id",))
db.rename_table("cmsplugin_file", "file_file")
db.rename_table("cmsplugin_filepublic", "file_publicfile")
db.alter_column('file_file', 'public_id', orm['file.file:public'])
示例9: forwards
def forwards(self, orm):
db.rename_table("text_text", "cmsplugin_text")
db.rename_table("text_publictext", "cmsplugin_textpublic")
db.rename_column("cmsplugin_textpublic", "publiccmsplugin_ptr_id", "cmspluginpublic_ptr_id")
db.alter_column("cmsplugin_text", "public_id", orm["text.text:public"])
try:
db.delete_foreign_key("cmsplugin_text", "public_id")
except:
pass
db.drop_primary_key("cmsplugin_textpublic")
db.create_primary_key("cmsplugin_textpublic", ("cmspluginpublic_ptr_id",))
db.foreign_key_sql("cmsplugin_text", "public_id", "cmsplugin_textpublic", "cmspluginpublic_ptr_id")
示例10: forwards
def forwards(self, orm):
db.rename_table("link_link", "cmsplugin_link")
db.rename_table("link_publiclink", "cmsplugin_linkpublic")
db.rename_column("cmsplugin_linkpublic", "publiccmsplugin_ptr_id", "cmspluginpublic_ptr_id")
db.alter_column("cmsplugin_link", "public_id", orm["link.link:public"])
try:
db.delete_foreign_key("cmsplugin_link", "public_id")
except:
pass
db.drop_primary_key("cmsplugin_linkpublic")
db.create_primary_key("cmsplugin_linkpublic", ("cmspluginpublic_ptr_id",))
db.foreign_key_sql("cmsplugin_link", "public_id", "cmsplugin_linkpublic", "cmspluginpublic_ptr_id")
示例11: test_recursive_foreign_key_delete
def test_recursive_foreign_key_delete(self):
"""
Test that recursive foreign keys are deleted correctly (see #1065)
"""
Test = db.mock_model(model_name='Test', db_table='test_rec_fk_del',
db_tablespace='', pk_field_name='id',
pk_field_type=models.AutoField, pk_field_args=[])
db.create_table('test_rec_fk_del', [
('id', models.AutoField(primary_key=True, auto_created=True)),
('fk', models.ForeignKey(Test)),
])
db.execute_deferred_sql()
db.delete_foreign_key('test_rec_fk_del', 'fk_id')
示例12: forwards
def forwards(self, orm):
try:
db.delete_foreign_key('sentry_message', 'group_id')
db.delete_foreign_key('sentry_message', 'project_id')
db.delete_foreign_key('sentry_eventmapping', 'group_id')
db.delete_foreign_key('sentry_eventmapping', 'project_id')
except OperationalError:
pass
示例13: forwards
def forwards(self, orm):
# OMFG Get ready, we're going to change the primary key!
# Doing bad things, disabling triggers
db.execute("ALTER TABLE brainstorm_idea DISABLE TRIGGER ALL;")
# Dropping foreign key constraint
db.delete_foreign_key('brainstorm_idea', 'subsite_id')
db.execute('DROP INDEX brainstorm_idea_subsite_id_like')
db.delete_index('brainstorm_idea', ['subsite_id'])
# Removing primary key on 'Subsite', fields ['slug']
db.delete_primary_key(u'brainstorm_subsite')
# Adding primary key field 'Subsite.id'
db.add_column(u'brainstorm_subsite', u'id',
self.gf('django.db.models.fields.IntegerField')(blank=True, null=True))
# WOW. Have to manually create AutoFields. Thanks Django!
db.execute('CREATE SEQUENCE brainstorm_subsite_id_seq;')
db.execute("UPDATE brainstorm_subsite SET id = nextval('brainstorm_subsite_id_seq');")
db.execute("ALTER TABLE brainstorm_subsite ALTER COLUMN id SET DEFAULT nextval('brainstorm_subsite_id_seq');")
db.execute('ALTER SEQUENCE brainstorm_subsite_id_seq OWNED BY brainstorm_subsite.id;')
db.execute("SELECT setval('brainstorm_subsite_id_seq', q.i) FROM(SELECT MAX(id) i FROM brainstorm_subsite) q;")
# Now make it the pk
db.create_primary_key('brainstorm_subsite', ['id'])
# Updating foreign key values
db.execute('''UPDATE brainstorm_idea idea
SET subsite_id = subsite.id
FROM brainstorm_subsite subsite
WHERE(idea.subsite_id = subsite.slug);''')
# Casting the fk to an integer
db.execute("ALTER TABLE brainstorm_idea ALTER COLUMN subsite_id TYPE integer USING CAST(subsite_id AS integer);")
# Re-adding foreign key constraint
fk_sql = db.foreign_key_sql('brainstorm_idea', 'subsite_id', 'brainstorm_subsite', 'id')
db.execute(fk_sql)
# Changing field 'Subsite.slug' to a plain old slugfield
db.alter_column(u'brainstorm_subsite', 'slug', self.gf('django.db.models.fields.SlugField')(max_length=50))
# Adding unique constraint on 'Subsite', fields ['slug']
db.create_unique(u'brainstorm_subsite', ['slug'])
# Re-enabling triggers
db.execute("ALTER TABLE brainstorm_idea ENABLE TRIGGER ALL;")
开发者ID:crdunwel,项目名称:tcamp,代码行数:48,代码来源:0003_auto__add_field_subsite_id__chg_field_subsite_slug__del_unique_subsite.py
示例14: delete_dynamic_tables
def delete_dynamic_tables(*names):
db.start_transaction()
for model in get_dynamic_models(*names):
for f in model._meta.fields:
if isinstance(f, models.ForeignKey):
try:
db.delete_foreign_key(model._meta.db_table, f.column)
except ValueError:
pass
transaction.commit_unless_managed()
db.start_transaction()
for model in get_dynamic_models(*names):
db.delete_table(model._meta.db_table, cascade=True)
#db.commit_transaction()
transaction.commit_unless_managed()
示例15: backwards
def backwards(self, orm):
db.rename_table('socialmedia_socialmedia', 'utils_socialmedia')
if not db.dry_run:
# For permissions to work properly after migrating
orm['contenttypes.contenttype'].objects.filter(app_label='socialmedia', model='socialmedia').update(app_label='utils')
# Fix foreign key for accounts
db.delete_foreign_key('accounts_account_social_media', 'socialmedia_id')
sql = db.foreign_key_sql('accounts_account_social_media', 'socialmedia_id', 'utils_socialmedia', 'id')
db.execute(sql)
# Fix foreign key for contacts
db.delete_foreign_key('contacts_contact_social_media', 'socialmedia_id')
sql = db.foreign_key_sql('contacts_contact_social_media', 'socialmedia_id', 'utils_socialmedia', 'id')
db.execute(sql)