gpt4 book ai didi

python - 列 'django_migrations.id' 具有不受支持的类型 'serial' [使用 Amazon Redshift]

转载 作者:太空狗 更新时间:2023-10-29 21:59:34 25 4
gpt4 key购买 nike

我使用 django_celery 连接到 Amazon Redshift。要迁移数据库,在“makemigrations”之后我使用了命令“python manage.py migrate”,错误消息如下所示。

原因是 Redshift 不支持数据类型“serial”,但包含“serial”类型的“django_migrations”表是自动创建的。

如何停止 Django 迁移创建此表或避免在“django_migrations”表上使用序列号。

D:\code\test_celery_django>python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 441, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 93, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 47, in __init__
self.build_graph()
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 180, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 59, in applied_migrations
self.ensure_schema()
File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 53, in ensure_schema
editor.create_model(self.Migration)
File "C:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 286, in create_model
self.execute(sql, params or None)
File "C:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 111, in execute
cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.NotSupportedError: Column "django_migrations.id" has unsupported type "serial".

最佳答案

您是否正在尝试使用 Redshift 作为您的 Web 应用程序的后端数据库?这是个坏主意,Redshift 是一个数据仓库,因此单个查询性能和延迟都远非理想,更不用说 Redshift 不强制执行主键,这几乎肯定是 Django 期望的。

我的建议是使用 PostgreSQL。

关于python - 列 'django_migrations.id' 具有不受支持的类型 'serial' [使用 Amazon Redshift],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31266658/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com