Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psycopg2.errors.DuplicateTable: relation "health_check_db_testmodel" already exists #830

Closed
glennmatthews opened this issue Aug 18, 2021 · 1 comment · Fixed by #840
Closed
Assignees
Labels
type: bug Something isn't working as expected

Comments

@glennmatthews
Copy link
Contributor

Environment

  • Python version: 3.9
  • Nautobot version: 1.1.3-beta.1 (9f52e6e)

Steps to Reproduce

  1. Run an earlier version of Nautobot 1.1.x
  2. Upgrade to 9f52e6e
  3. Run nautobot-server migrate or nautobot-server post_upgrade

Expected Behavior

Server continues functioning

Observed Behavior

Performing database migrations...
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, dcim, dummy_plugin, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization
Running migrations:
  Applying extras.0012_healthchecktestmodel...Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
psycopg2.errors.DuplicateTable: relation "health_check_db_testmodel" already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/nautobot-server", line 5, in <module>
    main()
  File "/source/nautobot/core/cli.py", line 55, in main
    run_app(
  File "/source/nautobot/core/runner/runner.py", line 266, in run_app
    management.execute_from_command_line([runner_name, command] + command_args)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/source/nautobot/core/management/commands/post_upgrade.py", line 78, in handle
    call_command(
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 168, in call_command
    return command.execute(*args, **defaults)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 243, in handle
    post_migrate_state = executor.migrate(
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/operations/models.py", line 92, in database_forwards
    schema_editor.create_model(model)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 324, in create_model
    self.execute(sql, params or None)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 142, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.9/site-packages/cacheops/transaction.py", line 93, in execute
    result = self._no_monkey.execute(self, sql, params)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "health_check_db_testmodel" already exists

This appears likely to be a result of #819.

@FloLaco
Copy link
Contributor

FloLaco commented Aug 23, 2021

I have the same issue.
The PR #840 fix the issue for me

glennmatthews added a commit that referenced this issue Aug 23, 2021
hellerve added a commit to hellerve/nautobot that referenced this issue Aug 27, 2021
* next: (36 commits)
  Add release-notes for nautobot#852 and nautobot#853
  Fix nautobot#852 and nautobot#853, add regression test coverage (nautobot#854)
  Add release-notes for nautobot#493
  Add release-notes for nautobot#670 and nautobot#856
  Steps For API Key (nautobot#857)
  Doc Fix Only - update jobs docs regarding job failures (nautobot#670)
  AutoSlug with consistent API (nautobot#757)
  Add release-notes for nautobot#11 and nautobot#850
  Add documentation on how to write and preview documentation (nautobot#850)
  Added webhook suppot for plugins (nautobot#790)
  Add release-notes for nautobot#845 and nautobot#848
  Update index.md (nautobot#845)
  Update links to NAPALM (nautobot#848)
  Add release-note for nautobot#841
  Doc fixes started 8 6 21 (nautobot#841)
  Add release-notes for nautobot#652 and nautobot#830
  Don't use same db_table as previously created by health_check.db. Fixes nautobot#830 (nautobot#840)
  Add object variable lookup (nautobot#837)
  Add release-note for nautobot#718
  Fix nautobot#718: Computed field template overflow (nautobot#831)
  ...
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants