-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Projects using multiple databases cannot use django-pgviews outside of the default database.
I'm using django-pgviews on a project connected to two databases. In our case, the default database is quite small, while the 2nd database is large and could make valuable use of materialized views.
To support multiple databases, I think the following modifications need to be made:
-
Modify how connection cursors are obtained to make use of the connections dictionary:
-
Update view creation to refer to the database router's allow_migrate so views are only created within the appropriate database.
-
Update management commands to support running against specific databases, as migrate works. For example:
python manage.py sync_pgviews # default db python manage.py sync_pgviews --database=customers
In the end, the majority of users using a single database shouldn't notice any differences and everything will continue to function as normal 🤞
I have a proof of concept currently working on a fork. Would there be any interest in possibly incorporating these changes if I can put together a PR?