Skip to content

Conversation

@JudgeManz
Copy link

Issue

Current migrations require that the django-raster library's tables are created at the "default" database connection in settings.py. This did not allow the library to work with multiple databases and database routers if django-raster's tables weren't being created in the "default" database connection.

Solution

Modified migrations to allow django-raster to run migrations and create the tables in a different database connection. This allows the library to support the creation of tables in a different database such as when running "python manage.py migrate --database=db_name"

Migration Changes

Migration 0005: Changed the RunSQL function to RunPython so that migrations won't run into an error when the user enters "python manage.py migrate" when django-raster's tables are being created in a database that isn't in the "default" connection.

Migrations 0017, 0022, 0034, 0036: Added "db_alias = schema_editor.connection.alias" to let the migration use the database connection specified by the user or the router. Changed "for x in ModelName.object.all()" to "for x in ModelName.objects.using(db_alias).all()" in the migration python functions to use the specified database connection.

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