Skip to content

Commit

Permalink
Merge pull request #264 from technologiestiftung/staging
Browse files Browse the repository at this point in the history
Staging to prod: treeIds migration
  • Loading branch information
Jaszkowic authored Jun 4, 2024
2 parents 01bad90 + f0f7596 commit 0e41392
Show file tree
Hide file tree
Showing 6 changed files with 12,910 additions and 12,884 deletions.
6 changes: 3 additions & 3 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export type Database = {
gattung: string | null
gattung_deutsch: string | null
geom: unknown | null
gml_id: string | null
hausnr: string | null
id: string
kennzeich: string | null
Expand Down Expand Up @@ -154,7 +153,6 @@ export type Database = {
gattung?: string | null
gattung_deutsch?: string | null
geom?: unknown | null
gml_id?: string | null
hausnr?: string | null
id: string
kennzeich?: string | null
Expand Down Expand Up @@ -183,7 +181,6 @@ export type Database = {
gattung?: string | null
gattung_deutsch?: string | null
geom?: unknown | null
gml_id?: string | null
hausnr?: string | null
id?: string
kennzeich?: string | null
Expand Down Expand Up @@ -233,6 +230,7 @@ export type Database = {
Row: {
amount: number
id: number
included_in_map_layer: boolean | null
timestamp: string
tree_id: string
username: string | null
Expand All @@ -241,6 +239,7 @@ export type Database = {
Insert: {
amount: number
id?: number
included_in_map_layer?: boolean | null
timestamp: string
tree_id: string
username?: string | null
Expand All @@ -249,6 +248,7 @@ export type Database = {
Update: {
amount?: number
id?: number
included_in_map_layer?: boolean | null
timestamp?: string
tree_id?: string
username?: string | null
Expand Down
26 changes: 26 additions & 0 deletions supabase/migrations/20240530123349_fix_id_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +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_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;
Loading

0 comments on commit 0e41392

Please sign in to comment.