For discussion:
I am using DBViews where one view selects data from another view. In my use-case I do it because we have complex JSONB data in a (PostgreSQL) field that I am selecting and deconstructing to tabular data, which i then select from in multiple other views.
In the DependentView i am then using f"SELECT ... FROM {MainView._meta.db_table}". This creates a problem when i want to change MainView later on since that view cant be dropped because DependentView depends on it. With a DROP CASCADE this could be solved, but then the DependentView would be gone.
One workaround for now is to manually modify the migrations by adding operations to first empty and then recreate the DependentView (in both directions)
What would be nicer though is if there would be a way to specify
class DependentView(DBView):
depends_on=[MainView]
which would then make sure that if MainView changes, DependentView is first dropped, and then recreated after MainView is changed.
Does this sound like an interesting feature? If it does, I would be willing to put in time to contribute the code.
For discussion:
I am using DBViews where one view selects data from another view. In my use-case I do it because we have complex JSONB data in a (PostgreSQL) field that I am selecting and deconstructing to tabular data, which i then select from in multiple other views.
In the
DependentViewi am then usingf"SELECT ... FROM {MainView._meta.db_table}". This creates a problem when i want to changeMainViewlater on since that view cant be dropped becauseDependentViewdepends on it. With aDROP CASCADEthis could be solved, but then theDependentViewwould be gone.One workaround for now is to manually modify the migrations by adding operations to first empty and then recreate the
DependentView(in both directions)What would be nicer though is if there would be a way to specify
which would then make sure that if
MainViewchanges,DependentViewis first dropped, and then recreated afterMainViewis changed.Does this sound like an interesting feature? If it does, I would be willing to put in time to contribute the code.