pg-schema-diff
pg-schema-diff copied to clipboard
View support
Add support for views. A fully-supported view feature will be blocked until we can order on individual columns adds/drops.
Hi! Could you elaborate a bit on this? I thought the support was just a matter of issuing create or replace with the new definition.
Think of it like this. You have an existing view foobar that references columns fizzbuzz.color and fizzbuzz.value.
Your new schema has foobar but it references a new column fizzbuzz.new_value and it no longer references fizzbuzz.value, which is being dropped.
The SQL statement now needs to be ordered such that. that view is created or replace BEFORE the old value column is deleted (otherwise the old column drop will fail) but AFTER the column fizzbuzz.value is added.
Views can actually have a pretty complicated web of dependencies depending on how "advanced" you want your schema diffing support to go.
Well, this made me read the docs, and this is awful. Please excuse my initial ignorance, I got too spoiled by Oracle, where it just recompiles and invalidates the dependencies, so you can update objects in any order and just recompile invalid ones afterwards.
May be it would be enough at first to just detect and drop dependent views before table/view changes and recreate them later?
Very basic VIEW support was added. I won't close this out until the feature is as fleshed out as I would like.