omnivore/packages/db/migrations/0070.do.update_labels_table.sql

24 lines
729 B
MySQL
Raw Permalink Normal View History

2022-02-21 08:03:00 +00:00
-- Type: DO
-- Name: update_labels_table
-- Description: Update labels table and create link_labels table
BEGIN;
ALTER TABLE omnivore.labels
DROP COLUMN link_id,
ADD COLUMN color text NOT NULL DEFAULT '#000000',
2022-02-21 08:03:00 +00:00
ADD COLUMN description text,
ADD CONSTRAINT label_name_unique UNIQUE (user_id, name);
CREATE TABLE omnivore.link_labels (
2022-02-22 06:18:55 +00:00
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
2022-02-21 08:03:00 +00:00
link_id uuid NOT NULL REFERENCES omnivore.links ON DELETE CASCADE,
label_id uuid NOT NULL REFERENCES omnivore.labels ON DELETE CASCADE,
2022-02-22 06:18:55 +00:00
created_at timestamptz NOT NULL DEFAULT current_timestamp,
UNIQUE (link_id, label_id)
2022-02-21 08:03:00 +00:00
);
GRANT SELECT, INSERT, DELETE ON omnivore.link_labels TO omnivore_user;
2022-02-21 08:03:00 +00:00
COMMIT;