From b35c79761f3ff79f6937f6582fbe13e0bec9254e Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Sat, 27 Jul 2024 21:19:44 +0100 Subject: [PATCH] Drop the public from table references as we won't be in the public schema --- .../20240727194157_move_tags_to_join_table.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/migrations/20240727194157_move_tags_to_join_table.sql b/migrations/20240727194157_move_tags_to_join_table.sql index c18b3d6..cb39e75 100644 --- a/migrations/20240727194157_move_tags_to_join_table.sql +++ b/migrations/20240727194157_move_tags_to_join_table.sql @@ -1,16 +1,16 @@ -- Create a new join table to associate time_entries with tags -CREATE TABLE public.time_entry_tags ( - time_entry_id bigint not null references public.time_entries(id) on delete cascade, - tag_id bigint not null references public.tags(id) on delete cascade, +CREATE TABLE time_entry_tags ( + time_entry_id bigint not null references time_entries(id) on delete cascade, + tag_id bigint not null references tags(id) on delete cascade, primary key (time_entry_id, tag_id) ); -- Insert data into the new join table based on the existing time_entries and tags data -INSERT INTO public.time_entry_tags (time_entry_id, tag_id) +INSERT INTO time_entry_tags (time_entry_id, tag_id) SELECT time_entries.id, UNNEST(time_entries.tag_ids) AS tag_id -FROM public.time_entries +FROM time_entries WHERE time_entries.tag_ids IS NOT NULL; -- Remove the tag_ids array column from the time_entries table -ALTER TABLE public.time_entries +ALTER TABLE time_entries DROP COLUMN tag_ids;