我在这个问题中遇到了与用户相同的问题,但不幸的是答案没有解决任何问题。关于我遵循给定指示时发生的事情的一些评论:
当我尝试--delete-ghost-migrations
命令时出现错误
The app 'tixeng' does not appear to use migrations.
我向前推进了应用程序的方向和初始化迁移。然后我又试了--delete-ghost-migrations
一次
/Users/AaronPardes/Dropbox/Python/home_repos/squidtix/squidtix/virtualenvironments/squidtixENV/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
DeprecationWarning)
Running migrations for tixeng:
- Nothing to migrate.
- Loading initial data for tixeng.
Installed 0 object(s) from 0 fixture(s)
然后,我对模型进行了更改,并尝试为更改创建新的迁移。
^C(squidtixENV)Aarons-MacBook-Pro:squidtix AaronPardes$ ./manage.py schemamigration tixeng --auto
+ Added field for_sale on tixeng.SquidTic
Created 0002_auto__add_field_squidtic_for_sale.py. You can now apply this migration with: ./manage.py migrate tixeng
并应用迁移。
/Users/AaronPardes/Dropbox/Python/home_repos/squidtix/squidtix/virtualenvironments/squidtixENV /lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
DeprecationWarning)
Running migrations for tixeng:
- Migrating forwards to 0002_auto__add_field_squidtic_for_sale.
> tixeng:0002_auto__add_field_squidtic_for_sale
FATAL ERROR - The following SQL query failed: CREATE TABLE "_south_new_tixeng_squidtic" ("date_listed" datetime NOT NULL, "event_id" integer NOT NULL, "price" integer NOT NULL, "for_sale" bool NOT NULL DEFAULT 1, "id" integer PRIMARY KEY, "owner_id" integer)
The error was: table "_south_new_tixeng_squidtic" already exists
! Error found during real run of migration! Aborting.
! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.
! You *might* be able to recover with:
! The South developers regret this has happened, and would
! like to gently persuade you to consider a slightly
! easier-to-deal-with DBMS (one that supports DDL transactions)
! NOTE: The error which caused the migration to fail is further up.
Error in migration: tixeng:0002_auto__add_field_squidtic_for_sale
DatabaseError: table "_south_new_tixeng_squidtic" already exists
相关信息:
添加的字段:models.BooleanField(default = True)
创建的迁移:
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'SquidTic.for_sale'
db.add_column(u'tixeng_squidtic', 'for_sale',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'SquidTic.for_sale'
db.delete_column(u'tixeng_squidtic', 'for_sale')
models = {
u'accounts.myprofile': {
'Meta': {'object_name': 'MyProfile'},
'favourite_snack': ('django.db.models.fields.CharField', [], {'max_length': '5'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'mugshot': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'blank': 'True'}),
'privacy': ('django.db.models.fields.CharField', [], {'default': "'registered'", 'max_length': '15'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'my_profile'", 'unique': 'True', 'to': u"orm['auth.User']"})
},
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'tixeng.squidartist': {
'Meta': {'object_name': 'SquidArtist'},
'artist_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '20'})
},
u'tixeng.squidevent': {
'Meta': {'object_name': 'SquidEvent'},
'artist': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['tixeng.SquidArtist']", 'symmetrical': 'False'}),
'event_date': ('django.db.models.fields.DateTimeField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'venue': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tixeng.SquidVenue']"})
},
u'tixeng.squidtic': {
'Meta': {'object_name': 'SquidTic'},
'date_listed': ('django.db.models.fields.DateTimeField', [], {}),
'event': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['tixeng.SquidEvent']"}),
'for_sale': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['accounts.MyProfile']"}),
'price': ('django.db.models.fields.IntegerField', [], {'default': '0.0'})
},
u'tixeng.squidvenue': {
'Meta': {'object_name': 'SquidVenue'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'street_address': ('django.db.models.fields.CharField', [], {'max_length': '20'})
}
}
complete_apps = ['tixeng']