Skip to content

Commit

Permalink
Update 20240222084232_update_delete_pokerstory_proc.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWeathers committed Feb 22, 2024
1 parent 7aeaf0e commit 558cccd
Showing 1 changed file with 0 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ CREATE OR REPLACE PROCEDURE thunderdome.poker_story_delete(IN pokerid uuid, IN s
AS $$
DECLARE
active_storyid UUID;
story RECORD;
pos DOUBLE PRECISION = -1;
BEGIN
SET CONSTRAINTS thunderdome.poker_story_poker_id_position DEFERRED;

active_storyid := (SELECT b.active_story_id FROM thunderdome.poker b WHERE b.id = pokerid);
DELETE FROM thunderdome.poker_story WHERE id = storyid;

FOR story IN SELECT id, position FROM thunderdome.poker_story WHERE poker_id = pokerid ORDER BY position
LOOP
pos = pos + 1;

UPDATE thunderdome.poker_story SET position = pos WHERE id = story.id;
END LOOP;

IF active_storyid = storyid THEN
UPDATE thunderdome.poker SET last_active = NOW(), voting_locked = true, active_story_id = null
WHERE id = pokerid;
Expand Down

0 comments on commit 558cccd

Please sign in to comment.