Skip to content

fix: do not fail in initial migrations if PG_EXTRA_SEARCH_PATHS …#622

Open
zvolsky wants to merge 1 commit intobernardopires:masterfrom
zvolsky:feature/init_with_pg_extra_search_paths
Open

fix: do not fail in initial migrations if PG_EXTRA_SEARCH_PATHS …#622
zvolsky wants to merge 1 commit intobernardopires:masterfrom
zvolsky:feature/init_with_pg_extra_search_paths

Conversation

@zvolsky
Copy link
Copy Markdown

@zvolsky zvolsky commented Feb 17, 2020

Do not fail in initial migrations if PG_EXTRA_SEARCH_PATHS is defined.

If we have empty database (like after DROP/CREATE DATABASE), the table for tenant model is not created yet and in old code all ./manage.py commands (like migrate_schemas) will fail. Worse: The error message is not very descriptive so it is not much easy find a workaround (which is temporary comment out PG_EXTRA_SEARCH_PATHS in settings).

This merge request should handle this so the code will run during initial migrations and no change in settings is needed.

In new code we just check if the (tenant) table exists in database.

Best regards,
Mirek

@zvolsky
Copy link
Copy Markdown
Author

zvolsky commented Feb 17, 2020

Please close the older related #542

@zvolsky
Copy link
Copy Markdown
Author

zvolsky commented May 28, 2020

Seems this will be accepted never.
So good solution is following code in your settings:

import sys
if 'manage.py migrate' not in ' '.join(sys.argv).replace('makemigrations', 'migrate'):
    PG_EXTRA_SEARCH_PATHS = ['extensions']

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

Successfully merging this pull request may close these issues.

1 participant