“COLLATE”或附近的语法错误wagtail1.9 postgresql9.5.2

时间:2017-03-26 17:42:00

标签: django postgresql wagtail

由于此行python manage.py migrate

而运行ALTER TABLE wagtailcore_page ALTER COLUMN path TYPE VARCHAR(255) COLLATE "C"时出现此错误

https://github.com/wagtail/wagtail/blob/master/wagtail/wagtailcore/migrations/0001_squashed_0016_change_page_url_path_to_text_field.py#L130

我该如何解决?

更新

当然,这是:

Operations to perform:

  Synchronize unmigrated apps: staticfiles, wagtailsnippets, wagtailsites, modelcluster, messages
  Apply all migrations: wagtailusers, django_comments, wagtailadmin, sessions, admin, menu, wagtailcore, sites, auth, wagtailembeds, blog, wagtailsearch, contenttypes, wagtaildocs, taggit, django_comments_xtd, wagtailforms, wagtailredirects, wagtailimages
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying taggit.0001_initial... OK
  Applying taggit.0002_auto_20150616_2121... OK
  Applying wagtailimages.0001_initial... OK
  Applying wagtailcore.0001_squashed_0016_change_page_url_path_to_text_field...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 221, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/migrations/executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/migrations/executor.py", line 147, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/migrations/migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/migrations/operations/special.py", line 181, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/wagtail/wagtailcore/migrations/0001_squashed_0016_change_page_url_path_to_text_field.py", line 131, in set_page_path_collation
    """)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 107, in execute
    cursor.execute(sql, params)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/shapemywish/.virtualenvs/project/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: syntax error at or near "COLLATE"
LINE 2: ...tailcore_page ALTER COLUMN path TYPE VARCHAR(255) COLLATE "C...
                                                             ^

1 个答案:

答案 0 :(得分:1)

您可能拥有一个早于9.1的PostgreSQL版本(2011年首次发布,现在已不再支持),当引入排序规则时。

解决方案是升级到更新版本的PostgreSQL。