本文整理汇总了Python中south.db.db.drop_primary_key函数的典型用法代码示例。如果您正苦于以下问题:Python drop_primary_key函数的具体用法?Python drop_primary_key怎么用?Python drop_primary_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drop_primary_key函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: forwards
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",))
示例2: backwards
def backwards(self, orm):
db.drop_primary_key("cmsplugin_googlemappublic")
db.rename_column("cmsplugin_googlemappublic", "cmspluginpublic_ptr_id", "publiccmsplugin_ptr_id")
db.create_primary_key("cmsplugin_googlemappublic", ("publiccmsplugin_ptr_id",))
db.rename_table("cmsplugin_googlemap", "googlemap_googlemap")
db.rename_table("cmsplugin_googlemappublic", "googlemap_publicgooglemap")
db.alter_column('cmsplugin_googlemap', 'public_id', orm['googlemap.googlemap:public'])
示例3: test_primary_key
def test_primary_key(self):
"""
Test the primary key operations
"""
# SQLite backend doesn't support this yet.
if db.backend_name == "sqlite3":
return
db.create_table(
"test_pk",
[
("id", models.IntegerField(primary_key=True)),
("new_pkey", models.IntegerField()),
("eggs", models.IntegerField(unique=True)),
],
)
db.execute_deferred_sql()
# Remove the default primary key, and make eggs it
db.drop_primary_key("test_pk")
db.create_primary_key("test_pk", "new_pkey")
# Try inserting a now-valid row pair
db.execute("INSERT INTO test_pk (id, new_pkey, eggs) VALUES (1, 2, 3)")
db.execute("INSERT INTO test_pk (id, new_pkey, eggs) VALUES (1, 3, 4)")
db.delete_table("test_pk")
示例4: forwards
def forwards(self, orm):
db.create_index('cg_channel_featured_email', ['channel_id'])
db.drop_primary_key('cg_channel_featured_email')
# Adding field 'FeaturedEmail.id'
db.add_column('cg_channel_featured_email', 'id', orm['featured.featuredemail:id'])
示例5: forwards
def forwards(self, orm):
db.create_index('cg_channel_rating', ['user_id'])
db.create_index('cg_channel_rating', ['channel_id'])
db.drop_primary_key('cg_channel_rating')
# Adding field 'Rating.id'
db.add_column('cg_channel_rating', 'id', orm['ratings.rating:id'])
示例6: forwards
def forwards(self, orm):
db.create_index('cg_channel_added', ['channel_id'])
db.create_index('cg_channel_added', ['user_id'])
db.drop_primary_key('cg_channel_added')
# Adding field 'AddedChannel.id'
db.add_column('cg_channel_added', 'id', orm['channels.addedchannel:id'])
示例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_publishable
def forwards_publishable(self, orm):
'''
creation of publishable objects
TODO: sync publish_from
'''
# move the data
db.execute('''
INSERT INTO
`core_publishable` (old_id, content_type_id, %(cols_to)s)
SELECT
a.id, ct.id, %(cols_from)s
FROM
`%(table)s` a, `django_content_type` ct
WHERE
ct.`app_label` = '%(app_label)s' AND ct.`model` = '%(model)s';
''' % self.substitute
)
# add link to parent
db.add_column(self.table, 'publishable_ptr', models.IntegerField(null=True, blank=True))
# update the link
db.execute('''
UPDATE
`core_publishable` pub
JOIN `%(table)s` art ON (art.`id` = pub.`old_id`)
JOIN `django_content_type` ct ON (pub.`content_type_id` = ct.`id` AND ct.`app_label` = '%(app_label)s' AND ct.`model` = '%(model)s')
SET
art.`publishable_ptr` = pub.`id`;
''' % self.substitute
)
# remove constraints from all models reffering to us
self.alter_self_foreignkeys(orm)
# drop primary key
db.alter_column(self.table, 'id', models.IntegerField())
db.drop_primary_key(self.table)
# replace it with a link to parent
db.rename_column(self.table, 'publishable_ptr', 'publishable_ptr_id')
db.alter_column(self.table, 'publishable_ptr_id', models.OneToOneField(orm['core.Publishable'], null=False, blank=False))
# move data, that were pointing to us
self.move_self_foreignkeys(orm)
# drop duplicate columns
db.delete_column(self.table, 'id')
for column in self.cols_from:
db.delete_column(self.table, column)
示例11: forwards
def forwards(self, orm):
# we have to drop primary key, but it can't be AutoField
db.alter_column("sample_spam", "id", models.IntegerField())
db.drop_primary_key("sample_spam")
# Deleting field 'Spam.id'
# TODO:
# but we need to find any of our children
# because they contain constraint to us
db.delete_column("sample_spam", "id")
# Adding field 'Spam.id'
db.add_column("sample_spam", "id", models.AutoField(primary_key=True))
示例12: forwards
def forwards(self, orm):
db.rename_table("file_file", "cmsplugin_file")
db.rename_table("file_publicfile", "cmsplugin_filepublic")
db.alter_column('cmsplugin_file', 'public_id', orm['file.file:public'])
try:
db.delete_foreign_key('cmsplugin_file' ,'public_id')
except:
pass
db.drop_primary_key("cmsplugin_filepublic")
db.rename_column("cmsplugin_filepublic", "publiccmsplugin_ptr_id", "cmspluginpublic_ptr_id")
db.create_primary_key("cmsplugin_filepublic", ("cmspluginpublic_ptr_id",))
db.foreign_key_sql('cmsplugin_file' ,'public_id', 'cmsplugin_filepublic', 'cmspluginpublic_ptr_id')
示例13: test_primary_key
def test_primary_key(self):
"""
Test the primary key operations
"""
db.create_table("test_pk", [
('id', models.IntegerField(primary_key=True)),
('new_pkey', models.IntegerField()),
('eggs', models.IntegerField(unique=True)),
])
db.execute_deferred_sql()
db.start_transaction()
# Remove the default primary key, and make eggs it
db.drop_primary_key("test_pk")
db.create_primary_key("test_pk", "new_pkey")
# Try inserting a now-valid row pair
db.execute("INSERT INTO test_pk (id, new_pkey, eggs) VALUES (1, 2, 3), (1, 3, 4)")
db.rollback_transaction()
db.delete_table("test_pk")
示例14: forwards_publishable
def forwards_publishable(self, orm):
'''
creation of publishable objects
TODO: sync publish_from
'''
# move the data
# db.execute('''
# INSERT INTO
# `core_publishable` (old_id, content_type_id, %(cols_to)s)
# SELECT
# a.id, ct.id, %(cols_from)s
# FROM
# `%(table)s` a, `django_content_type` ct
# WHERE
# ct.`app_label` = '%(app_label)s' AND ct.`model` = '%(model)s';
# ''' % self.substitute
# )
# add link to parent
db.add_column(self.table, 'publishable_ptr', models.IntegerField(null=True, blank=True))
# update the link
# db.execute('''
# UPDATE
# `core_publishable` pub
# JOIN `%(table)s` art ON (art.`id` = pub.`old_id`)
# JOIN `django_content_type` ct ON (pub.`content_type_id` = ct.`id` AND ct.`app_label` = '%(app_label)s' AND ct.`model` = '%(model)s')
# SET
# art.`publishable_ptr` = pub.`id`;
# ''' % self.substitute
# )
# remove constraints from all models reffering to us
# self.alter_self_foreignkeys(orm)
# drop primary key
db.alter_column(self.table, 'id', models.IntegerField())
db.drop_primary_key(self.table)
# replace it with a link to parent
db.rename_column(self.table, 'publishable_ptr', 'publishable_ptr_id')
db.alter_column(self.table, 'publishable_ptr_id', models.ForeignKey(orm['core.Publishable'], unique=True))
db.create_primary_key(self.table, 'publishable_ptr_id')
# make it a FK
# db.execute(
# 'ALTER TABLE `%s` ADD CONSTRAINT `publishable_ptr_id_refs_id_%s` FOREIGN KEY (`publishable_ptr_id`) REFERENCES `core_publishable` (`id`);' % (
# self.table,
# abs(hash((self.table, 'core_publishable'))),
# )
# )
# move data, that were pointing to us
# self.move_self_foreignkeys(orm)
# drop duplicate columns
db.delete_column(self.table, 'id')
for column in self.cols_from:
db.delete_column(self.table, column)
示例15: forwards
def forwards(self, orm):
db.drop_primary_key('cg_tag_map')
# Adding field 'TagMap.id'
db.add_column('cg_tag_map', 'id', orm['labels.tagmap:id'])