本文整理汇总了Python中south.db.db.rename_column函数的典型用法代码示例。如果您正苦于以下问题:Python rename_column函数的具体用法?Python rename_column怎么用?Python rename_column使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rename_column函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rename_db_column
def rename_db_column(model_class, old_name, new_name):
""" Renomear uma coluna de banco de dados do sensor. """
table_name = model_class._meta.db_table
db.start_transaction()
db.rename_column(table_name, old_name, new_name)
logger.debug("Renamed column '%s' to '%s' on %s" % (old_name, new_name, table_name))
db.commit_transaction()
示例2: backwards
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'])
示例3: test_dry_rename
def test_dry_rename(self):
"""
Test column renaming while --dry-run is turned on (should do nothing)
See ticket #65
"""
cursor = connection.cursor()
db.create_table("test_drn", [('spam', models.BooleanField(default=False))])
# Make sure we can select the column
cursor.execute("SELECT spam FROM test_drn")
# Rename it
db.dry_run = True
db.rename_column("test_drn", "spam", "eggs")
db.dry_run = False
cursor.execute("SELECT spam FROM test_drn")
db.commit_transaction()
db.start_transaction()
try:
cursor.execute("SELECT eggs FROM test_drn")
except:
pass
else:
self.fail("Dry-renamed new column could be selected!")
db.rollback_transaction()
db.delete_table("test_drn")
db.start_transaction()
示例4: forwards
def forwards(self, orm):
# Adding model 'User'
db.create_table('tomato_user', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=20, unique=True)),
))
db.send_create_signal('tomato', ['User'])
db.rename_column('tomato_element', 'owner', 'owner_str')
db.rename_column('tomato_connection', 'owner', 'owner_str')
db.add_column('tomato_element', 'owner',
self.gf('django.db.models.fields.related.ForeignKey')(related_name='elements', null=True, to=orm['tomato.User']),
keep_default=False)
# Adding field 'Connection.owner'
db.add_column('tomato_connection', 'owner',
self.gf('django.db.models.fields.related.ForeignKey')(related_name='connections', null=True, to=orm['tomato.User']),
keep_default=False)
db.add_column('tomato_network', 'owner',
self.gf('django.db.models.fields.related.ForeignKey')(related_name='networks', null=True, to=orm['tomato.User']),
keep_default=False)
db.add_column('tomato_template', 'owner',
self.gf('django.db.models.fields.related.ForeignKey')(related_name='templates', null=True, to=orm['tomato.User']),
keep_default=False)
# Changing field 'OpenVZ.template'
db.alter_column('tomato_openvz', 'template_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['tomato.Template'], null=True))
示例5: backwards
def backwards(self, orm):
db.delete_column('l_t_troncon', 'geom')
db.rename_column('l_t_troncon', 'geom_3d', 'geom')
db.delete_column('e_t_evenement', 'geom')
db.rename_column('e_t_evenement', 'geom_3d', 'geom')
db.alter_column('l_t_troncon', 'geom_cadastre', self.gf('django.contrib.gis.db.models.fields.LineStringField')(srid=settings.SRID, dim=3, null=True, spatial_index=False))
示例6: backwards
def backwards(self, orm):
# Adding field 'OutputSettings.daily_states_filename'
db.add_column('ScenarioCreator_outputsettings', 'daily_states_filename',
self.gf('django.db.models.fields.CharField')(max_length=255, blank=True, null=True),
keep_default=False)
# Adding field 'OutputSettings.maximum_iterations_for_daily_output'
db.add_column('ScenarioCreator_outputsettings', 'maximum_iterations_for_daily_output',
self.gf('django.db.models.fields.PositiveIntegerField')(default=3, blank=True, null=True),
keep_default=False)
# Adding field 'OutputSettings.save_all_daily_outputs'
db.add_column('ScenarioCreator_outputsettings', 'save_all_daily_outputs',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
# Adding field 'OutputSettings.map_directory'
db.add_column('ScenarioCreator_outputsettings', 'map_directory',
self.gf('django.db.models.fields.CharField')(max_length=255, blank=True, null=True),
keep_default=False)
# Adding field 'OutputSettings.write_map_output'
db.rename_column('ScenarioCreator_outputsettings', 'save_map_output', 'write_map_output' )
# Deleting field 'OutputSettings.save_daily_unit_states'
db.delete_column('ScenarioCreator_outputsettings', 'save_daily_unit_states')
开发者ID:sniperpj21,项目名称:SpreadModel,代码行数:26,代码来源:0034_auto__del_field_outputsettings_daily_states_filename__del_field_output.py
示例7: forwards
def forwards(self, orm):
# Adding model 'Faction'
db.create_table('representative_faction', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)),
('short', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)),
))
db.send_create_signal('representative', ['Faction'])
# Deleting field 'Representative.faction_en'
db.delete_column('representative_representative', 'faction_en')
# Deleting field 'Representative.faction_ka'
db.delete_column('representative_representative', 'faction_ka')
# Renaming column for 'Representative.faction' to match new field type.
db.rename_column('representative_representative', 'faction', 'faction_id')
# Changing field 'Representative.faction'
db.alter_column('representative_representative', 'faction_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['representative.Faction']))
# Adding index on 'Representative', fields ['faction']
db.create_index('representative_representative', ['faction_id'])
# Removing M2M table for field parties on 'Cabinet'
db.delete_table(db.shorten_name('representative_cabinet_parties'))
# Adding M2M table for field factions on 'Cabinet'
m2m_table_name = db.shorten_name('representative_cabinet_factions')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('cabinet', models.ForeignKey(orm['representative.cabinet'], null=False)),
('faction', models.ForeignKey(orm['representative.faction'], null=False))
))
db.create_unique(m2m_table_name, ['cabinet_id', 'faction_id'])
开发者ID:araneta,项目名称:shenmartav,代码行数:34,代码来源:0024_auto__add_faction__del_field_representative_faction_en__del_field_repr.py
示例8: backwards
def backwards(self, orm):
try:
# Removing index on 'PricingObject', fields ['type']
db.delete_index(u'ralph_scrooge_pricingobject', ['type_id'])
except utils.DatabaseError:
pass
# Removing unique constraint on 'TeamManager', fields ['manager', 'team']
db.delete_unique(u'ralph_scrooge_teammanager', ['manager_id', 'team_id'])
# Deleting model 'PricingObjectType'
db.delete_table(u'ralph_scrooge_pricingobjecttype')
# Deleting model 'PricingObjectModel'
db.delete_table(u'ralph_scrooge_pricingobjectmodel')
# Deleting model 'TeamManager'
db.delete_table(u'ralph_scrooge_teammanager')
# Adding field 'AssetInfo.model'
db.rename_column(u'ralph_scrooge_assetinfo', 'model_old_id', 'model_id')
# Adding field 'PricingObject.color'
db.add_column(u'ralph_scrooge_pricingobject', 'color',
self.gf('django.db.models.fields.PositiveIntegerField')(default=255),
keep_default=False)
# Deleting field 'PricingObject.model'
db.delete_column(u'ralph_scrooge_pricingobject', 'model_id')
# Renaming column for 'PricingObject.type' to match new field type.
db.rename_column(u'ralph_scrooge_pricingobject', 'type_id', 'type')
# Changing field 'PricingObject.type'
db.alter_column(u'ralph_scrooge_pricingobject', 'type', self.gf('django.db.models.fields.PositiveIntegerField')())
开发者ID:allegro,项目名称:ralph_pricing,代码行数:34,代码来源:0005_auto__add_pricingobjecttype__add_pricingobjectmodel__add_teammanager__.py
示例9: 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",))
示例10: forwards
def forwards(self, orm):
# Renaming field 'Prize.deprecated_provided' to 'Prize.provided'
db.rename_column(u'tracker_prize', 'deprecated_provided', 'provided')
# Adding field 'Prize.creator'
db.add_column(u'tracker_prize', 'creator',
self.gf('django.db.models.fields.CharField')(default='', max_length=64, blank=True),
keep_default=False)
# Adding field 'Prize.creatoremail'
db.add_column(u'tracker_prize', 'creatoremail',
self.gf('django.db.models.fields.CharField')(default='', max_length=64, blank=True),
keep_default=False)
# Adding field 'Prize.creatorwebsite'
db.add_column(u'tracker_prize', 'creatorwebsite',
self.gf('django.db.models.fields.CharField')(default='', max_length=64, blank=True),
keep_default=False)
# Adding field 'Prize.state'
db.add_column(u'tracker_prize', 'state',
self.gf('django.db.models.fields.CharField')(default='PENDING', max_length=32),
keep_default=False)
# Removing M2M table for field contributors on 'Prize'
db.delete_table(db.shorten_name(u'tracker_prize_contributors'))
# Deleting field 'Donor.prizecontributorwebsite'
db.delete_column(u'tracker_donor', 'prizecontributorwebsite')
# Deleting field 'Donor.prizecontributoremail'
db.delete_column(u'tracker_donor', 'prizecontributoremail')
示例11: backwards
def backwards(self, orm):
# Removing index on 'Restaurant', fields ['location']
db.delete_index(u'api_restaurant', ['location_id'])
# Adding model 'Restaurant_Holiday'
db.create_table(u'api_restaurant_holiday', (
('closed_date', self.gf('django.db.models.fields.DateTimeField')()),
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('restaurant', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['api.Restaurant'])),
))
db.send_create_signal(u'api', ['Restaurant_Holiday'])
# Deleting model 'RestaurantOpenHours'
db.delete_table(u'api_restaurantopenhours')
# Deleting model 'RestaurantHoliday'
db.delete_table(u'api_restaurantholiday')
# Deleting model 'Location'
db.delete_table(u'api_location')
# Adding field 'Restaurant.closed_every_other_weekend_initial_weekend'
db.add_column(u'api_restaurant', 'closed_every_other_weekend_initial_weekend',
self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True),
keep_default=False)
# Deleting field 'Restaurant.closed_every_other_weekend_initial_weekend_sat'
db.delete_column(u'api_restaurant', 'closed_every_other_weekend_initial_weekend_sat')
# Renaming column for 'Restaurant.location' to match new field type.
db.rename_column(u'api_restaurant', 'location_id', 'location')
# Changing field 'Restaurant.location'
db.alter_column(u'api_restaurant', 'location', self.gf('django.db.models.fields.IntegerField')())
开发者ID:heronyang,项目名称:plate-api,代码行数:34,代码来源:0007_auto__del_restaurant_holiday__add_restaurantopenhours__add_restauranth.py
示例12: backwards
def backwards(self, orm):
# Renaming field 'Prize.provided' to 'Prize.deprecated_provided'
db.rename_column(u'tracker_prize', 'provided', 'deprecated_provided')
# Deleting field 'Prize.creator'
db.delete_column(u'tracker_prize', 'creator')
# Deleting field 'Prize.creatoremail'
db.delete_column(u'tracker_prize', 'creatoremail')
# Deleting field 'Prize.creatorwebsite'
db.delete_column(u'tracker_prize', 'creatorwebsite')
# Deleting field 'Prize.state'
db.delete_column(u'tracker_prize', 'state')
# Adding M2M table for field contributors on 'Prize'
m2m_table_name = db.shorten_name(u'tracker_prize_contributors')
db.create_table(m2m_table_name, (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('prize', models.ForeignKey(orm['tracker.prize'], null=False)),
('donor', models.ForeignKey(orm['tracker.donor'], null=False))
))
db.create_unique(m2m_table_name, ['prize_id', 'donor_id'])
# Adding field 'Donor.prizecontributorwebsite'
db.add_column(u'tracker_donor', 'prizecontributorwebsite',
self.gf('django.db.models.fields.URLField')(max_length=200, null=True, blank=True),
keep_default=False)
# Adding field 'Donor.prizecontributoremail'
db.add_column(u'tracker_donor', 'prizecontributoremail',
self.gf('django.db.models.fields.EmailField')(unique=True, max_length=128, null=True, blank=True),
keep_default=False)
示例13: backwards
def backwards(self, orm):
# Removing index on 'Sponsor', fields ['organization']
db.delete_index(u'sponsor_sponsor', ['organization_id'])
# Deleting model 'Organization'
db.delete_table(u'sponsor_organization')
# Adding field 'Sponsor.name_user'
db.add_column(u'sponsor_sponsor', 'name_user',
self.gf('django.db.models.fields.CharField')(default=1, max_length=50),
keep_default=False)
# Adding field 'Sponsor.join_date'
db.add_column(u'sponsor_sponsor', 'join_date',
self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, default=1, blank=True),
keep_default=False)
# Adding field 'Sponsor.password'
db.add_column(u'sponsor_sponsor', 'password',
self.gf('django.db.models.fields.CharField')(default=1, max_length=50),
keep_default=False)
# Adding field 'Sponsor.email'
db.add_column(u'sponsor_sponsor', 'email',
self.gf('django.db.models.fields.EmailField')(default=1, max_length=75, unique=True),
keep_default=False)
# Deleting field 'Sponsor.user'
db.delete_column(u'sponsor_sponsor', 'user_id')
# Renaming column for 'Sponsor.organization' to match new field type.
db.rename_column(u'sponsor_sponsor', 'organization_id', 'organization')
# Changing field 'Sponsor.organization'
db.alter_column(u'sponsor_sponsor', 'organization', self.gf('django.db.models.fields.CharField')(max_length=50))
开发者ID:darkmatter08,项目名称:Kommonly,代码行数:35,代码来源:0006_auto__add_organization__del_field_sponsor_name_user__del_field_sponsor.py
示例14: forwards
def forwards(self, orm):
# Renaming field 'State.date' to 'State.captured_at'
db.rename_column('greenhub_state', 'date', 'captured_at')
# Changing field 'Message.data'
db.alter_column('greenhub_message', 'data', self.gf('django.db.models.fields.CharField')(max_length=1000))
示例15: backwards
def backwards(self, orm):
# Adding index on 'Tag', fields ['tipo_tags']
db.create_index(u"usuario_tag", ["tipo_tags_id"])
# Adding model 'Tipo_Tag'
db.create_table(
u"usuario_tipo_tag",
(
("tabela", self.gf("django.db.models.fields.CharField")(max_length=100)),
(u"id", self.gf("django.db.models.fields.AutoField")(primary_key=True)),
("tipo", self.gf("django.db.models.fields.CharField")(max_length=100)),
),
)
db.send_create_signal(u"usuario", ["Tipo_Tag"])
# Removing M2M table for field comcopia on 'Tag'
db.delete_table(db.shorten_name(u"usuario_tag_comcopia"))
# Renaming column for 'Tag.tipo_tags' to match new field type.
db.rename_column(u"usuario_tag", "tipo_tags", "tipo_tags_id")
# Changing field 'Tag.tipo_tags'
db.alter_column(
u"usuario_tag",
"tipo_tags_id",
self.gf("django.db.models.fields.related.ForeignKey")(to=orm["usuario.Tipo_Tag"]),
)
开发者ID:wt3c,项目名称:helpdesk,代码行数:26,代码来源:0017_auto__del_tipo_tag__chg_field_tag_tipo_tags__del_index_tag_tipo_tags.py