列'django_migrations.id'具有不支持的类型'serial'[with Amazon Redshift] [英] Column 'django_migrations.id' has unsupported type 'serial' [ with Amazon Redshift]

查看:338
本文介绍了列'django_migrations.id'具有不支持的类型'serial'[with Amazon Redshift]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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 
追溯(最近的最后一次调用):
文件manage.py,第10行,模块>
execute_from_command_line(sys.argv)
文件C:\Python27\lib\site- packages\django\core\management\__init __。py,第338行,在execute_from_command_line
utility.execute()
文件C:\Python27\lib\site- packages\django\core\management\__init __。py,第330行,执行
self.fetch_command(子命令).run_from_argv(self.argv)
文件C:\Python27\lib\site- packages\django\core\management\base.py ,行390,在run_from_argv
self.execute(* args,** cmd_options)
文件C:\Python27\lib\site- packages\django\core\management\\ \\ base.py,第441行,执行
output = self.handle(* args,** options)
文件C:\Python27\lib\site-packages\django \core\management\commands\migrate.py,第93行,在句柄
executor = MigrationExecutor(connection,self.migration _progress_callback)
文件C:\Python27\lib\site-packages\django\db\migrations\executor.py,第19行,__init__
self.loader = MigrationLoader(self.connection)
文件C:\Python27\lib\site-packages\django\db\migrations\loader.py,第47行,__init__
self.build_graph()
文件C:\Python27\lib\site-packages\django\db\migrations\loader.py,第180行,build_graph
自身.applied_migrations = recorder.applied_migrations()
文件C:\Python27\lib\site- packages\django\db\migrations\recorder.py,第59行中的apply_migrations
self.ensure_schema()
文件C:\Python27\lib\site- packages\django\db\migrations\recorder.py,第53行,在ensure_schema
editor.create_model(self.Migration)
文件C:\Python27\lib\site-packages\django $ db $\\

文件C:\Python27 \lib\(第28行)在create_model
self.execute(sql,params或None) site-packages\django\db\backends\base\schema.py,第111行,执行
cursor.execute(sql,params)
文件C:\Python27 \lib\site- packages\django\db\backends\utils.py,第79行,执行
return super(CursorDebugWrapper,self).execute(sql,params)
文件C:\Python27\lib\site- packages\django\db\backends\utils.py,行64,执行
return self.cursor.execute(sql, params)
文件C:\Python27\lib\site- packages\django\db\utils.py,第97行,__exit__
six.reraise(dj_exc_type,dj_exc_value ,traceback)
文件C:\Python27\lib\site- packages\django\db\backends\utils.py,第62行,执行
return self。 cursor.ex ecute(sql)
django.db.utils.NotSupportedError:列django_migrations.id不支持类型serial。


解决方案

您是否尝试使用Redshift作为后端数据库你的网络应用程序?这是一个坏主意,Redshift是一个数据仓库,因此个性化查询性能和延迟远远不够,更不用说Redshift不会强制执行主键,这几乎是Django所期望的。



我的建议,使用PostgreSQL。


I use django_celery with connecting to Amazon Redshift. To migrate database, after "makemigrations" I used command "python manage.py migrate" and error message show up as shown below.

The reason is Redshift does not support data type 'serial' but the 'django_migrations' table that contain 'serial' type is automatically created.

How to stop Django Migrations create this table or avoid using serial on 'django_migrations' table.

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".

解决方案

Are you trying to use Redshift as the backend database for your web application? That's a bad idea, Redshift is a data warehouse and as such individual query performance and latency are far from great, not to mention that Redshift doesn't enforce primary keys, which almost surely Django expects.

My recommendation, use PostgreSQL.

这篇关于列'django_migrations.id'具有不支持的类型'serial'[with Amazon Redshift]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆