jasoncodes / activerecord_views

Automatic PostgreSQL database view creation for ActiveRecord
MIT License
35 stars 10 forks source link

Automatically recreate dependant views when there’s incompatibilities #9

Closed jasoncodes closed 9 years ago

jasoncodes commented 10 years ago

B depends on A. A has an incompatible change made. A cannot be updated without dropping, which requires dropping B as well. Drop B, create A, create B inside a single transaction.

jasoncodes commented 10 years ago
SELECT DISTINCT(cl2.relname)
FROM pg_depend dep
INNER JOIN pg_class cl ON dep.refobjid = cl.oid
INNER JOIN pg_rewrite ON dep.objid = pg_rewrite.oid
INNER JOIN pg_class cl2 ON pg_rewrite.ev_class = cl2.oid
WHERE cl.oid != cl2.oid AND deptype = 'n' AND cl.relname = $1;