Skip to content

Commit

Permalink
fix: migrations failing due to dependent views
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisgsmith committed Nov 16, 2024
1 parent c0e3657 commit f659c1e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions api/migrations/schema/V1.14.00__uploader.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
DO $$
DECLARE drop_views_query text;
BEGIN
SELECT 'DROP VIEW ' || string_agg (table_name, ', ') || ' CASCADE;'
FROM information_schema.views
INTO drop_views_query
WHERE table_schema = 'midas'
AND table_name LIKE 'v_%';

IF (drop_views_query IS NULL) THEN
RAISE NOTICE 'not dropping views on schema midas -- no views found to drop';
ELSE
EXECUTE drop_views_query;
END IF;
END
$$;

-- checked db and there are no null instrument geometries
ALTER TABLE instrument ALTER COLUMN "geometry" TYPE geometry(Point, 4326);
ALTER TABLE instrument ALTER COLUMN "geometry" SET NOT NULL;
Expand Down

0 comments on commit f659c1e

Please sign in to comment.