1

この質問のユーザーと同じ問題がありましたが、残念ながら答えは何も解決しませんでした. 与えられた指示に従ったときに何が起こったのかについてのいくつかのコメント:

コマンドを実行しようとすると--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']
4

2 に答える 2