# TASK \[kubernetes : Migrate database\] failing

**URL:** <https://forum.ansible.com/t/task-kubernetes-migrate-database-failing/31068>\
**Category:** AWX Project\
**Tags:** awx, kubernetes\
**Created:** [August 19, 2019, 9:00am UTC](https://forum.ansible.com/t/task-kubernetes-migrate-database-failing/31068 "2019-08-19T09:00:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashok\_kumar](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@ashok\_kumar](https://forum.ansible.com/u/ashok_kumar)\
**Post date:** [August 19, 2019, 9:00am UTC](https://forum.ansible.com/t/task-kubernetes-migrate-database-failing/31068/1 "2019-08-19T09:00:36Z")

</div>

Hi Team,

I am trying to install AWX using kubernetes with external postgres. But while executing Migrate database task getting below error.

TASK [kubernetes : Migrate database] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

fatal: [localhost]: FAILED! =\> {“changed”: true, “cmd”: “kubectl -n 2304378531 exec ansible-tower-management – bash -c "awx-manage migrate --noinput"”, “delta”: “0:00:05.503190”, “end”: “2019-08-19 13:14:24.285694”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2019-08-19 13:14:18.782504”, “stderr”: “Traceback (most recent call last):\n File "/usr/bin/awx-manage", line 11, in \n load\_entry\_point(‘awx==4.0.0.0’, ‘console\_scripts’, ‘awx-manage’)()\n File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/ **init**.py", line 140, in manage\n execute\_from\_command\_line(sys.argv)\n File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/ **init**.py", line 364, in execute\_from\_command\_line\n utility.execute()\n File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/ **init**.py", line 356, in execute\n self.fetch\_command(subcommand).run\_from\_argv(self.argv)\n File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 283, in run\_from\_argv\n self.execute(\*args, \*\*cmd\_options)\n File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 330, in execute\n output = self.handle(\*args, \*\*options)\n File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/commands/migrate.py", line 86, in handle\n executor.loader.check\_consistent\_history(connection)\n File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/loader.py", line 298, in check\_consistent\_history\n connection.alias,\ndjango.db.migrations.exceptions.InconsistentMigrationHistory: Migration oauth2\_provider.0001\_initial is applied before its dependency main.0025\_v330\_add\_oauth\_activity\_stream\_registrar on database ‘default’.\ncommand terminated with exit code 1”, “stderr\_lines”: [“Traceback (most recent call last):”, " File "/usr/bin/awx-manage", line 11, in “, " load\_entry\_point(‘awx==4.0.0.0’, ‘console\_scripts’, ‘awx-manage’)()”, " File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/ **init**.py", line 140, in manage", " execute\_from\_command\_line(sys.argv)“, " File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/ **init**.py", line 364, in execute\_from\_command\_line”, " utility.execute()“, " File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/ **init**.py", line 356, in execute”, " self.fetch\_command(subcommand).run\_from\_argv(self.argv)“, " File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 283, in run\_from\_argv”, " self.execute(\*args, \*\*cmd\_options)“, " File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 330, in execute”, " output = self.handle(\*args, \*\*options)“, " File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/commands/migrate.py", line 86, in handle”, " executor.loader.check\_consistent\_history(connection)“, " File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/migrations/loader.py", line 298, in check\_consistent\_history”, " connection.alias,", “django.db.migrations.exceptions.InconsistentMigrationHistory: Migration oauth2\_provider.0001\_initial is applied before its dependency main.0025\_v330\_add\_oauth\_activity\_stream\_registrar on database ‘default’.”, “command terminated with exit code 1”], “stdout”: “”, “stdout\_lines”: }

to retry, use: --limit @/Users/ashok.g/Desktop/awx-devel/installer/install.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

localhost : ok=18 changed=8 unreachable=0 failed=1

Anyone Please help me on this

---

<div class="post-metadata">

**Author:** ![Raja\_V](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@Raja\_V](https://forum.ansible.com/u/Raja_V)\
**Post date:** [August 19, 2019, 11:30am UTC](https://forum.ansible.com/t/task-kubernetes-migrate-database-failing/31068/2 "2019-08-19T11:30:38Z")

</div>

What changes you had made in the inventory file, can you share that

---

<div class="post-metadata">

**Author:** ![ashok\_kumar](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@ashok\_kumar](https://forum.ansible.com/u/ashok_kumar)\
**Post date:** [August 19, 2019, 11:36am UTC](https://forum.ansible.com/t/task-kubernetes-migrate-database-failing/31068/3 "2019-08-19T11:36:20Z")

</div>

Hi raja,

please find the attached inventory file.

Thanks,  
Ashok.G

> **(attachments)**
>
> [inventory.rtf](https://forum.ansible.com/uploads/short-url/39UxhDrVujgpsGiK74OUvE1074N.rtf) (6.15 KB)

---

<div class="post-metadata">

**Author:** ![AlanCoding](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alancoding/32/301_2.png) [@AlanCoding](https://forum.ansible.com/u/AlanCoding)\
**Post date:** [August 19, 2019, 12:48pm UTC](https://forum.ansible.com/t/task-kubernetes-migrate-database-failing/31068/4 "2019-08-19T12:48:58Z")

</div>

Are you installing onto a fresh database? If so, this message seems like inconsistent behavior from the Django migration dependency resolver. This dependency was added in AWX 1.0.7, I would not be surprised if upgrading from certain versions around that time hit this (but doesn’t sound like this describes your case). Let me just throw this out there as one of the things to try

check your current state:  
awx-manage showmigrations

back out the migration which is a dependency of the other:  
awx-manage migrate oauth2\_provider zero

then move forward again:  
awx-manage migrate

You might want to keep some backups around if you try this.

---

<div class="post-metadata">

**Author:** ![Raja\_V](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@Raja\_V](https://forum.ansible.com/u/Raja_V)\
**Post date:** [August 19, 2019, 2:31pm UTC](https://forum.ansible.com/t/task-kubernetes-migrate-database-failing/31068/5 "2019-08-19T14:31:29Z")

</div>

AWX database is created in the external pg server and its up and reachable
