Postgres DB

Hi,

I was trying to backup DB(backup.yml) and restore DB(restore.yml) from the backup. It was not successful.

So, erased all tower binaries and was trying to perform a fresh tower install. But fresh install (install.yml) fails with error,
IntegrityError: duplicate key value violates undex"\nDETAIL: Key (typname, typnamespace)=(django_migrations_id_seq, 2200) already exists

Can anybody please guide? should I remove the key? if yes, how can it be achieved?

P.S: backup.yml, restore.yml and install.yml are the scripts from Ansible bundle.

TASK [preflight : Preflight check - check Tower license type] ****************************************************************

fatal: [tnode3.abc.com]: FAILED! => {“changed”: true, “cmd”: “awx-manage check_license”, “delta”: “0:00:02.243”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2019-03-14 17:13:55.509133”, “stderr”: “Traceback (most recent call la, in \n load_entry_point(‘awx==3.2.5’, ‘console_scripts’, ‘awx-manage’)()\n File "/lib/python2.7/site-packages/awFile "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/init.py", line 354, in execute_from_comma”/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/init.py", line 328, in execute\n django.setupython2.7/site-packages/django/init.py", line 18, in setup\n apps.populate(settings.INSTALLED_APPS)\n File "/var/libs/django/apps/registry.py", line 115, in populate\n app_config.ready()\n File "/lib/python2.7/site-packages/awx/conf/app/python2.7/site-packages/awx/main/utils/handlers.py", line 357, in configure_external_logger\n File "/var/lib/awx/venv/awx/init.py", line 49, in getattr\n return getattr(self.wrapped, name)\n File "/lib/python2.7/site-packages/awx/con\n File "/usr/lib64/python2.7/contextlib.py", line 35, in exit\n self.gen.throw(type, value, traceback)\n File "/tings.py", line 64, in _log_database_error\n File "/lib/python2.7/site-packages/awx/main/utils/db.py", line 13, in get_towawx/venv/awx/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in init\n self.build_graph()\n Filsite-packages/django/db/migrations/loader.py", line 191, in build_graph\n self.applied_migrations = recorder.applied_migralib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations\n self.ensure_schema()\n Fi/site-packages/django/db/migrations/recorder.py", line 53, in ensure_schema\n editor.create_model(self.Migration)\n File te-packages/django/db/backends/base/schema.py", line 286, in create_model\n self.execute(sql, params or None)\n File "/vackages/django/db/backends/base/schema.py", line 111, in execute\n cursor.execute(sql, params)\n File "/var/lib/awx/venvdb/backends/utils.py", line 64, in execute\n return self.cursor.execute(sql, params)\n File "/var/lib/awx/venv/awx/lib/py", line 98, in exit\n six.reraise(dj_exc_type, dj_exc_value, traceback)\n File "/var/lib/awx/venv/awx/lib/python2.7py", line 62, in execute\n return self.cursor.execute(sql)\ndjango.db.utils.IntegrityError: duplicate key value violates undex"\nDETAIL: Key (typname, typnamespace)=(django_migrations_id_seq, 2200) already exists.“, “stderr_lines”: [“Traceback (mawx-manage", line 9, in ”, " load_entry_point(‘awx==3.2.5’, ‘console_scripts’, ‘awx-manage’)()”, " File "/lib/py line 107, in manage", " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/init.py", line utility.execute()“, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/init.py", line 32 File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/init.py", line 18, in setup”, " apps.populate(settingwx/venv/awx/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate", " app_config.ready()“, " File \pps.py", line 18, in ready”, " File "/lib/python2.7/site-packages/awx/main/utils/handlers.py", line 357, in configure_extev/awx/lib/python2.7/site-packages/django/conf/init.py", line 49, in getattr", " return getattr(self._wrapped, namees/awx/conf/settings.py", line 386, in getattr", " File "/usr/lib64/python2.7/contextlib.py", line 35, in exit", “k)”, " File "/lib/python2.7/site-packages/awx/conf/settings.py", line 64, in _log_database_error", " File "/lib/python2.7ine 13, in get_tower_migration_version", " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/migrations/loadf.build_graph()“, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/migrations/loader.py", line 191, in bs = recorder.applied_migrations()”, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/migrations/recorder. self.ensure_schema()“, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/migrations/recorder.py", linate_model(self.Migration)”, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/backends/base/schema.py", lcute(sql, params or None)“, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/backends/base/schema.py", le(sql, params)”, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execut params)“, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/utils.py", line 98, in exit”, " six.rack)“, " File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute”, " r.db.utils.IntegrityError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"", “DETAIL: Key (typnameq, 2200) already exists.”], “stdout”: “”, “stdout_lines”: }

…ignoring

[tnode3.abc.com] TASK: preflight : Preflight check - check Tower license type (debug)>

please reach out support for this issue.

If it is a restore from backup so a relational db is a db and db rules apply. Two choices. Drop the primary key (bad choice) or truncate first.