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

[Solution] Unable to create the django_migrations -relation already exists #695

Open
benshaji-sequoiaat opened this issue Sep 15, 2023 · 1 comment

Comments

@benshaji-sequoiaat
Copy link

I'd like to publish a solution to a problem which i'm sure some would face in future.
If you are familiar, the error is not very obvious and it explains something implicit.

When you run ./manage.py migrate , you would see a long traceback along with this at the end.
migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (relation "django_migrations" already exists. This in Django world means issues with db inconsistencies and likely hard to get back. I had faced this issue myself couple of time.

The issue is in your public schema where you store your tenant info. In my case, its tenant_tenant and tenant_domain in public. If you look close there could be some schemas which are created but not showing up in the actual database schema list. This could be because the schema was not created successfully or some other issues.

Just remove the entries which you donot see in the list of db schema from tenant_domain and then the refs from tenant_tenant.
I will not encourage numbers into schema names as well. Then do run the migration again

Feel free to ask in the comments incase of any questions :)

@classwood
Copy link

classwood commented Mar 23, 2024

This insight helped my project and saved my data!!
Thank you so much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants