我在models.py中添加了一个新模型。我成功完成了makemigrations。在makemigrations期间,我没有遇到任何问题。但是当我尝试将此模型迁移到数据库服务器时,我收到错误django.db.utils.DatabaseError: ORA-00955: name is already used by an existing object.
我确信没有其他模型名称与此新模型名称。
能否请您告诉我这是什么问题和解决方案。提前致谢
models.py
class ProdServersMountPoints(models.Model):
mountpoint = models.CharField(max_length=100)
check_fabs_servers = models.BooleanField()
check_oc_servers = models.BooleanField()
class Meta:
db_table = 'PROD_SERVERS_MOUNTPOINTS'
def __str__(self):
return str(self.mountpoint)
错误:
(venv_2.7.12) -bash-4.1$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, fabi, sessions
Running migrations:
Applying fabi.0002_auto_20171205_0057...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 96, in database_forwards
schema_editor.create_model(model)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 295, in create_model
self.execute(sql, params or None)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 112, in execute
cursor.execute(sql, params)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/scratch/kvkumari/tools_setup/Python/framework/venv_2.7.12/lib/python2.7/site-packages/django/db/backends/oracle/base.py", line 481, in execute
return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-00955: name is already used by an existing object
答案 0 :(得分:0)
为什么不打印出失败的sql并确定是什么原因,请编辑以下内容:
“ / scratch / kvkumari / tools_setup / Python / framework / venv_2.7.12 / lib / python2.7 / site-packages / django / db / backends / oracle / base.py”, 就在第481行之前,执行函数称为add:
print query
这将向您显示失败的sql查询。然后,您可以删除或重命名失败的sql表或对象