Added support for db_alias in migrations #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.