django.db.utils.ProgrammingError:列am.amcanorder不存在

时间:2016-12-01 07:20:07

标签: python django postgresql

我使用PostgreSQL作为我的数据库并使用django租户模式。但是,当我运行以下命令python manage.py migrate_schemas --shared时,我收到错误

(checkpoint_env) 

G:\Django_Projects\RackNole\checkpoint_shashi_2\checkpoint_shashi_2>python manage.py migrate_schemas --shared
System check identified some issues:

WARNINGS:
checkpoint.MultiSelectResponse.response: (fields.W340) null has no effect on ManyToManyField.
=== Running migrate for schema public
System check identified some issues:

WARNINGS:
checkpoint.MultiSelectResponse.response: (fields.W340) null has no effect on ManyToManyField.
Operations to perform:
  Apply all migrations: website, checkpoint, account, django_comments, redirects, core, admin, twitter, galleries, tastypie, customers, auth, sites, blog, generic, contenttypes, sessions, conf, forms, pages, socialaccount
Running migrations:
  Rendering model states... DONE
  Applying core.0002_auto_20150414_2140...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\core\management\__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\core\management\base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\tenant_schemas\management\commands\migrate_schemas.py", line 42, in handle
    self.run_migrations(self.schema_name, settings.SHARED_APPS)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\tenant_schemas\management\commands\migrate_schemas.py", line 65, in run_migrations
    command.execute(*self.args, **self.options)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\core\management\base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\core\management\commands\migrate.py", line 200, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\migrations\executor.py", line 92, in migrate
    self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\migrations\executor.py", line 121, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\migrations\executor.py", line 198, in apply_migration
    state = migration.apply(state, schema_editor)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\migrations\migration.py", line 123, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\migrations\operations\fields.py", line 201, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\backends\base\schema.py", line 482, in alter_field
    old_db_params, new_db_params, strict)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\backends\base\schema.py", line 491, in _alter_field
    fk_names = self._constraint_names(model, [old_field.column], foreign_key=True)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\backends\base\schema.py", line 911, in _constraint_names
    constraints = self.connection.introspection.get_constraints(cursor, model._meta.db_table)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\tenant_schemas\postgresql_backend\introspection.py", line 287, in get_constraints
    'table': table_name,
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\backends\utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\backends\utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "G:\Py_Envs\Racknole\checkpoint_env\lib\site-packages\django\db\backends\utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column am.amcanorder does not exist
LINE 13:                         WHEN am.amcanorder THEN

1 个答案:

答案 0 :(得分:2)

在PostgreSQL中,最多9.5 amcanorderpg_am目录列。在PostgreSQL 9.6 it was removed中。显然,django-tenant-schemas使用它。