我正在尝试为我的应用程序运行测试,它给出的消息就像
django.db.utils.ProgrammingError: column "status" cannot be cast automatically to type integer
HINT: Specify a USING expression to perform the conversion.
哦,这是因为我已经改变了CharField
使用IntegerField
SQL 语法(虽然迁移是为了这个改变而创建的)
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