summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-01-06 19:06:47 +0200
committerKyren223 <Kyren223@proton.me>2025-01-06 19:06:47 +0200
commitc0f55da0c433f6f1851e3717e60b87c16c89844d (patch)
tree2123ef17779a01996557abd8a4d878948de01887
parent14caa1959cbda309d297fe2c1adc01692decfb7a (diff)
Fixed network deletion error due to incorrect syntax in SQL trigger,
also this is bad practice to modify a migration (they should be immutable) but didn't want to have one with syntax errors and I will be refactoring and splitting this one huge migration into multiple separate migrations later on
-rw-r--r--migrations/20241026174345_init.sql10
1 files changed, 6 insertions, 4 deletions
diff --git a/migrations/20241026174345_init.sql b/migrations/20241026174345_init.sql
index e4f0f78..e22ecf0 100644
--- a/migrations/20241026174345_init.sql
+++ b/migrations/20241026174345_init.sql
@@ -106,10 +106,12 @@ BEGIN
UPDATE users_networks SET
position = position - 1
WHERE user_id IN (
- SELECT user_id FROM users_networks WHERE network_id = OLD.network_id
- ) AND position > OLD.position;
-
- DELETE FROM users_networks WHERE network_id = OLD.network_id;
+ SELECT user_id FROM users_networks WHERE network_id = OLD.id
+ ) AND position > (
+ SELECT position FROM users_networks WHERE user_id = users_networks.user_id AND network_id = OLD.id
+ );
+
+ DELETE FROM users_networks WHERE network_id = OLD.id;
END
-- +goose StatementEnd