Skip to content

Commit

Permalink
fix: bad migration (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaszkowic authored Jun 4, 2024
1 parent 4519eb8 commit f0f7596
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion supabase/migrations/20240530123349_fix_id_columns.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
ALTER TABLE trees_watered DROP CONSTRAINT fk_trees_watered_trees;
UPDATE trees_watered SET tree_id = (SELECT gml_id FROM trees WHERE trees.id = trees_watered.tree_id);

ALTER TABLE trees_adopted DROP CONSTRAINT fk_trees_adopted_trees;
UPDATE trees_adopted SET tree_id = (SELECT gml_id FROM trees WHERE trees.id = trees_adopted.tree_id);

UPDATE trees SET id = gml_id;
ALTER TABLE trees DROP COLUMN gml_id;

ALTER TABLE trees_watered
ADD CONSTRAINT fk_trees_watered_trees
FOREIGN KEY (tree_id)
REFERENCES trees (id)
ON DELETE CASCADE
ON UPDATE CASCADE;

ALTER TABLE trees_adopted
ADD CONSTRAINT fk_trees_adopted_trees
FOREIGN KEY (tree_id)
REFERENCES trees (id)
ON DELETE CASCADE
ON UPDATE CASCADE;

ALTER TABLE trees DROP COLUMN gml_id;

DROP TRIGGER insert_uuid on public.trees;
DROP FUNCTION public.uuid_insert_trigger;

0 comments on commit f0f7596

Please sign in to comment.