feat: swap out drizzle for supabase in label, list and workspace routers

This commit is contained in:
Henry
2024-04-15 20:29:01 +01:00
parent 1712a1a41b
commit b695f7bdf3
10 changed files with 257 additions and 176 deletions

View File

@@ -0,0 +1,23 @@
CREATE OR REPLACE FUNCTION reorder_list(board_id BIGINT, list_id BIGINT, current_index INT, new_index INT)
RETURNS VOID
LANGUAGE SQL
AS $$
UPDATE list
SET index =
CASE
WHEN index = current_index AND id = list_id THEN new_index
WHEN current_index < new_index AND index > current_index AND index <= new_index THEN index - 1
WHEN current_index > new_index AND index >= new_index AND index < current_index THEN index + 1
ELSE index
END
WHERE "boardId" = board_id;
$$;
CREATE OR REPLACE FUNCTION shift_list_index(board_id BIGINT, list_index INT)
RETURNS VOID
LANGUAGE SQL
AS $$
UPDATE list
SET index = index - 1
WHERE "boardId" = board_id AND index > list_index AND "deletedAt" IS NULL;
$$;