Skip to content

Commit c923b5c

Browse files
authored
Merge pull request #296 from technologiestiftung/chore/ready-for-2025
chore/ready for 2025
2 parents 3110130 + ae9433f commit c923b5c

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,5 @@ cython_debug/
281281
sql/trees_trees_2022-11-09T12-28-18.sql
282282
sql/trees_bezirk_mitte_table_2022-11-08T16-32-58.sql
283283
sql/*.dump
284+
# user specific cursor rules
285+
.cursor/rules/*

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,40 @@ npm test
168168

169169
On CI the Supabase is started automagically. See [.github/workflows/tests.yml](.github/workflows/tests.yml)
170170

171+
172+
## Database Caveats
173+
174+
To not hardcode values in the edge functions we are using materialized views.
175+
176+
- `most_frequent_tree_species`
177+
- `total_tree_species_count`
178+
- `waterings_with_location`
179+
180+
In case you need to restore the data from a backup you need to disable the triggers first.
181+
182+
```sql
183+
ALTER TABLE trees DISABLE TRIGGER tg_refresh_trees_count_mv;
184+
ALTER TABLE trees DISABLE TRIGGER tg_refresh_most_frequent_tree_species_mv;
185+
ALTER TABLE trees DISABLE TRIGGER tg_refresh_total_tree_species_count_mv;
186+
```
187+
188+
After restore is done, refresh the materialized views and re-enable our specific triggers.
189+
190+
```sql
191+
-- Manually refresh all materialized views
192+
REFRESH MATERIALIZED VIEW CONCURRENTLY total_tree_species_count;
193+
REFRESH MATERIALIZED VIEW CONCURRENTLY most_frequent_tree_species;
194+
REFRESH MATERIALIZED VIEW CONCURRENTLY trees_count;
195+
196+
-- Re-enable our specific triggers
197+
ALTER TABLE trees ENABLE TRIGGER tg_refresh_trees_count_mv;
198+
ALTER TABLE trees ENABLE TRIGGER tg_refresh_most_frequent_tree_species_mv;
199+
ALTER TABLE trees ENABLE TRIGGER tg_refresh_total_tree_species_count_mv;
200+
```
201+
202+
203+
204+
171205
## Contributors ✨
172206

173207
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "jest --runInBand",
88
"lint": "eslint ./**/*.ts ",
99
"format": "prettier ./**/*.ts --write",
10-
"dev:supabase:functions": "supabase functions serve --env-file .env",
10+
"dev:supabase:functions": "supabase functions serve --no-verify-jwt --env-file supabase/.env",
1111
"supabase:types:local": "supabase gen types --local > src/database.ts"
1212
},
1313
"engines": {

0 commit comments

Comments
 (0)