drop position trigger on labels table and sort labels by name returned by labels api

This commit is contained in:
Hongbo Wu
2023-10-12 10:39:35 +08:00
parent 135999fa83
commit b0f0dba53d
3 changed files with 28 additions and 1 deletions

View File

@ -54,7 +54,7 @@ export const labelsResolver = authorized<LabelsSuccess, LabelsError>(
user: { id: uid },
},
order: {
position: 'ASC',
name: 'ASC',
},
})
})

View File

@ -0,0 +1,10 @@
-- Type: DO
-- Name: drop_position_trigger_ob_labels
-- Description: Drop increment_label_position and decrement_label_position trigger on omnivore.labels table
BEGIN;
DROP TRIGGER IF EXISTS increment_label_position ON omnivore.labels;
DROP TRIGGER IF EXISTS decrement_label_position ON omnivore.labels;
COMMIT;

View File

@ -0,0 +1,17 @@
-- Type: UNDO
-- Name: drop_position_trigger_ob_labels
-- Description: Drop increment_label_position and decrement_label_position trigger on omnivore.labels table
BEGIN;
CREATE TRIGGER decrement_label_position
AFTER DELETE ON omnivore.labels
FOR EACH ROW
EXECUTE FUNCTION update_label_position();
CREATE TRIGGER increment_label_position
BEFORE INSERT ON omnivore.labels
FOR EACH ROW
EXECUTE FUNCTION update_label_position();
COMMIT;