pg-schema-diff icon indicating copy to clipboard operation
pg-schema-diff copied to clipboard

View support

Open bplunkett-stripe opened this issue 1 year ago • 4 comments
trafficstars

Add support for views. A fully-supported view feature will be blocked until we can order on individual columns adds/drops.

bplunkett-stripe avatar May 29 '24 16:05 bplunkett-stripe

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.

Scorg avatar Sep 17 '24 07:09 Scorg

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.

bplunkett-stripe avatar Sep 18 '24 02:09 bplunkett-stripe

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?

Scorg avatar Sep 20 '24 16:09 Scorg

Very basic VIEW support was added. I won't close this out until the feature is as fleshed out as I would like.

bplunkett-stripe avatar Aug 11 '25 02:08 bplunkett-stripe