我正在尝试为我的应用程序运行测试,它给出了像
这样的消息django.db.utils.ProgrammingError: column "status" cannot be cast automatically to type integer
HINT: Specify a USING expression to perform the conversion.
哦,这是因为我使用SQL语法将CharField
更改为IntegerField
(虽然为此更改创建了迁移)
ALTER TABLE accounts ALTER COLUMN status TYPE integer USING (status::integer);
因此,在运行test
命令时,在创建测试数据库时失败。
有什么方法吗?
更新: 现在我正在使用http s://pypi.python.org/pypi/django-test-without-migrations/
使用第三方应用程序跳过运行迁移的部分现在正在创建测试表但是没有缓存表
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 128, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 229, in sync_apps
sql, references = connection.creation.sql_create_model(model, no_style(), seen_models)
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/django/db/backends/creation.py", line 82, in sql_create_model
db_params = f.db_parameters(connection=self.connection)
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 548, in db_parameters
type_string = self.db_type(connection)
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/jsonfield/fields.py", line 73, in db_type
db_type = cache.get(cache_key)
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/django/core/cache/backends/db.py", line 65, in get
"WHERE cache_key = %%s" % table, [key])
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/naveen/ENV/automaticfleet/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "accounts_cache" does not exist