# Postgres DB

**URL:** <https://forum.ansible.com/t/postgres-db/29890>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [March 15, 2019, 1:30am UTC](https://forum.ansible.com/t/postgres-db/29890 "2019-03-15T01:30:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sindhuja\_Koneru](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@Sindhuja\_Koneru](https://forum.ansible.com/u/Sindhuja_Koneru)\
**Post date:** [March 15, 2019, 1:30am UTC](https://forum.ansible.com/t/postgres-db/29890/1 "2019-03-15T01:30:00Z")

</div>

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](http://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](http://tnode3.abc.com/)] TASK: preflight : Preflight check - check Tower license type (debug)\>

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [March 15, 2019, 1:54am UTC](https://forum.ansible.com/t/postgres-db/29890/2 "2019-03-15T01:54:21Z")

</div>

please reach out support for this issue.

---

<div class="post-metadata">

**Author:** ![Gaetano\_Giacalone](https://avatars.discourse-cdn.com/v4/letter/g/e56c9b/32.png) [@Gaetano\_Giacalone](https://forum.ansible.com/u/Gaetano_Giacalone)\
**Post date:** [March 15, 2019, 5:01am UTC](https://forum.ansible.com/t/postgres-db/29890/3 "2019-03-15T05:01:27Z")

</div>

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.
