0

我正在从配置文件模型设置更改为扩展用户模型。我正在尝试根据本指南设置我的南迁移。我有一些其他模型引用了 User 模型,因此当我自动生成我的模式迁移时,我得到了以下几行:

db.alter_column(u'app_model', 'user', 
  self.gf('django.db.models.fields.related.ForeignKey')(to=orm['app.user']))

问题是,当我尝试迁移时,这些迁移会导致 South 崩溃:

FATAL ERROR - The following SQL query failed: INSERT INTO "_south_new_app_model" () SELECT  FROM "app_model";
The error was: near ")": syntax error
 ! 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: app:0018_auto__chg_field_model_user.py
DatabaseError: near ")": syntax error

注意:这是使用./manage.py schemamigration app --auto. 我没有编辑它。

问题是,我在乎吗?数据库中存储的引用类型相同,我已经完成了重命名表的步骤。alter_table如果我从迁移中删除这些行,一切似乎都会继续工作。这是一个可怕的、可怕的想法,还是可以?

4

1 回答 1

1

Sqlite3 是问题所在。正如您在此处看到的,sqlite3 仅支持有限的 alter table操作子集,因此导致South迁移失败。如果您需要这样做,您必须将测试数据库移植到另一个支持alter table. 我建议,有时迁移可能会很棘手,您可能认为它正在工作,但测试它总是更好。

如果您认为工作正常,那么请继续忽略该错误,但请注意,它现在可能工作但可能迁移没有成功,稍后您会在开发环境中发现与数据库相关的奇怪错误。

于 2013-04-29T16:08:32.937 回答