Skip to content

Commit 0e41392

Browse files
authored
Merge pull request #264 from technologiestiftung/staging
Staging to prod: treeIds migration
2 parents 01bad90 + f0f7596 commit 0e41392

File tree

6 files changed

+12910
-12884
lines changed

6 files changed

+12910
-12884
lines changed

src/database.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export type Database = {
125125
gattung: string | null
126126
gattung_deutsch: string | null
127127
geom: unknown | null
128-
gml_id: string | null
129128
hausnr: string | null
130129
id: string
131130
kennzeich: string | null
@@ -154,7 +153,6 @@ export type Database = {
154153
gattung?: string | null
155154
gattung_deutsch?: string | null
156155
geom?: unknown | null
157-
gml_id?: string | null
158156
hausnr?: string | null
159157
id: string
160158
kennzeich?: string | null
@@ -183,7 +181,6 @@ export type Database = {
183181
gattung?: string | null
184182
gattung_deutsch?: string | null
185183
geom?: unknown | null
186-
gml_id?: string | null
187184
hausnr?: string | null
188185
id?: string
189186
kennzeich?: string | null
@@ -233,6 +230,7 @@ export type Database = {
233230
Row: {
234231
amount: number
235232
id: number
233+
included_in_map_layer: boolean | null
236234
timestamp: string
237235
tree_id: string
238236
username: string | null
@@ -241,6 +239,7 @@ export type Database = {
241239
Insert: {
242240
amount: number
243241
id?: number
242+
included_in_map_layer?: boolean | null
244243
timestamp: string
245244
tree_id: string
246245
username?: string | null
@@ -249,6 +248,7 @@ export type Database = {
249248
Update: {
250249
amount?: number
251250
id?: number
251+
included_in_map_layer?: boolean | null
252252
timestamp?: string
253253
tree_id?: string
254254
username?: string | null
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ALTER TABLE trees_watered DROP CONSTRAINT fk_trees_watered_trees;
2+
UPDATE trees_watered SET tree_id = (SELECT gml_id FROM trees WHERE trees.id = trees_watered.tree_id);
3+
4+
ALTER TABLE trees_adopted DROP CONSTRAINT fk_trees_adopted_trees;
5+
UPDATE trees_adopted SET tree_id = (SELECT gml_id FROM trees WHERE trees.id = trees_adopted.tree_id);
6+
7+
UPDATE trees SET id = gml_id;
8+
9+
ALTER TABLE trees_watered
10+
ADD CONSTRAINT fk_trees_watered_trees
11+
FOREIGN KEY (tree_id)
12+
REFERENCES trees (id)
13+
ON DELETE CASCADE
14+
ON UPDATE CASCADE;
15+
16+
ALTER TABLE trees_adopted
17+
ADD CONSTRAINT fk_trees_adopted_trees
18+
FOREIGN KEY (tree_id)
19+
REFERENCES trees (id)
20+
ON DELETE CASCADE
21+
ON UPDATE CASCADE;
22+
23+
ALTER TABLE trees DROP COLUMN gml_id;
24+
25+
DROP TRIGGER insert_uuid on public.trees;
26+
DROP FUNCTION public.uuid_insert_trigger;

0 commit comments

Comments
 (0)