From 4153142eb0015d014930ae1c3d2e11c2c2a72895 Mon Sep 17 00:00:00 2001 From: Erza Bytyci Date: Mon, 6 Jul 2026 23:42:38 +0000 Subject: [PATCH] fix migration --- ...d_global_search_fts_indexes_immutable.sql} | 36 ++++++++++--------- gradesa/data/schema.sql | 30 ++++++++++++++++ gradesa/playwright-report/index.html | 2 +- gradesa/test-results/.last-run.json | 12 ++++--- 4 files changed, 57 insertions(+), 23 deletions(-) rename gradesa/data/migrations/{00058_add_global_search_fts_indexes.sql => 00058_add_global_search_fts_indexes_immutable.sql} (61%) diff --git a/gradesa/data/migrations/00058_add_global_search_fts_indexes.sql b/gradesa/data/migrations/00058_add_global_search_fts_indexes_immutable.sql similarity index 61% rename from gradesa/data/migrations/00058_add_global_search_fts_indexes.sql rename to gradesa/data/migrations/00058_add_global_search_fts_indexes_immutable.sql index 35f2bf0..220c851 100644 --- a/gradesa/data/migrations/00058_add_global_search_fts_indexes.sql +++ b/gradesa/data/migrations/00058_add_global_search_fts_indexes_immutable.sql @@ -2,7 +2,7 @@ CREATE INDEX IF NOT EXISTS html_pages_search_fts_idx ON html_pages USING GIN ( to_tsvector( - 'simple', + 'pg_catalog.simple'::regconfig, COALESCE(title, '') || ' ' || COALESCE(description, '') || ' ' || COALESCE(content, '') ) ); @@ -10,20 +10,20 @@ CREATE INDEX IF NOT EXISTS html_pages_search_fts_idx CREATE INDEX IF NOT EXISTS free_form_exercises_search_fts_idx ON free_form_exercises USING GIN ( - to_tsvector('simple', COALESCE(title, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(title, '')) ); CREATE INDEX IF NOT EXISTS free_form_questions_search_fts_idx ON free_form_questions USING GIN ( - to_tsvector('simple', COALESCE(question, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(question, '')) ); CREATE INDEX IF NOT EXISTS multichoice_exercises_search_fts_idx ON multichoice_exercises USING GIN ( to_tsvector( - 'simple', + 'pg_catalog.simple'::regconfig, COALESCE(title, '') || ' ' || COALESCE(exercise_description, '') ) ); @@ -31,16 +31,18 @@ CREATE INDEX IF NOT EXISTS multichoice_exercises_search_fts_idx CREATE INDEX IF NOT EXISTS multichoice_content_search_fts_idx ON multichoice_content USING GIN ( - to_tsvector('simple', COALESCE(content_value, '') || ' ' || COALESCE(correct_answer, '')) + to_tsvector( + 'pg_catalog.simple'::regconfig, + COALESCE(content_value, '') || ' ' || COALESCE(correct_answer, '') + ) ); CREATE INDEX IF NOT EXISTS click_exercises_search_fts_idx ON click_exercises USING GIN ( to_tsvector( - 'simple', - COALESCE(title, '') || ' ' || COALESCE(category, '') || ' ' || - COALESCE(target_words::text, '') || ' ' || COALESCE(all_words::text, '') + 'pg_catalog.simple'::regconfig, + COALESCE(title, '') || ' ' || COALESCE(category, '') ) ); @@ -48,7 +50,7 @@ CREATE INDEX IF NOT EXISTS fill_gap_exercises_search_fts_idx ON fill_gap_exercises USING GIN ( to_tsvector( - 'simple', + 'pg_catalog.simple'::regconfig, COALESCE(title, '') || ' ' || COALESCE(source_text, '') || ' ' || COALESCE(source_html, '') ) ); @@ -56,47 +58,47 @@ CREATE INDEX IF NOT EXISTS fill_gap_exercises_search_fts_idx CREATE INDEX IF NOT EXISTS fill_gap_gaps_search_fts_idx ON fill_gap_gaps USING GIN ( - to_tsvector('simple', COALESCE(token_text, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(token_text, '')) ); CREATE INDEX IF NOT EXISTS dnd_exercises_search_fts_idx ON dnd_exercises USING GIN ( - to_tsvector('simple', COALESCE(title, '') || ' ' || COALESCE(description, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(title, '') || ' ' || COALESCE(description, '')) ); CREATE INDEX IF NOT EXISTS dnd_match_exercises_search_fts_idx ON dnd_match_exercises USING GIN ( - to_tsvector('simple', COALESCE(title, '') || ' ' || COALESCE(description, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(title, '') || ' ' || COALESCE(description, '')) ); CREATE INDEX IF NOT EXISTS dnd_match_pairs_search_fts_idx ON dnd_match_pairs USING GIN ( - to_tsvector('simple', COALESCE(left_item, '') || ' ' || COALESCE(right_item, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(left_item, '') || ' ' || COALESCE(right_item, '')) ); CREATE INDEX IF NOT EXISTS memory_game_exercises_search_fts_idx ON memory_game_exercises USING GIN ( - to_tsvector('simple', COALESCE(title, '') || ' ' || COALESCE(description, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(title, '') || ' ' || COALESCE(description, '')) ); CREATE INDEX IF NOT EXISTS memory_game_pairs_search_fts_idx ON memory_game_pairs USING GIN ( - to_tsvector('simple', COALESCE(left_item, '') || ' ' || COALESCE(right_item, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(left_item, '') || ' ' || COALESCE(right_item, '')) ); CREATE INDEX IF NOT EXISTS jumbled_sentence_exercises_search_fts_idx ON jumbled_sentence_exercises USING GIN ( - to_tsvector('simple', COALESCE(title, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(title, '')) ); CREATE INDEX IF NOT EXISTS jumbled_sentence_sentences_search_fts_idx ON jumbled_sentence_sentences USING GIN ( - to_tsvector('simple', COALESCE(sentence, '')) + to_tsvector('pg_catalog.simple'::regconfig, COALESCE(sentence, '')) ); diff --git a/gradesa/data/schema.sql b/gradesa/data/schema.sql index 3aed67a..3e04f18 100644 --- a/gradesa/data/schema.sql +++ b/gradesa/data/schema.sql @@ -89,6 +89,8 @@ CREATE TABLE public.click_exercises ( source_html text ); +CREATE INDEX click_exercises_search_fts_idx ON public.click_exercises USING gin (to_tsvector('simple'::regconfig, ((COALESCE(title, ''::text) || ' '::text) || COALESCE(category, ''::text)))); + ALTER TABLE public.click_exercises ADD CONSTRAINT click_exercises_all_words_target_words_key UNIQUE (all_words, target_words); @@ -172,6 +174,8 @@ CREATE TABLE public.dnd_exercises ( description text ); +CREATE INDEX dnd_exercises_search_fts_idx ON public.dnd_exercises USING gin (to_tsvector('simple'::regconfig, ((COALESCE(title, ''::text) || ' '::text) || COALESCE(description, ''::text)))); + ALTER TABLE public.dnd_exercises ADD CONSTRAINT dnd_exercises_created_by_fkey FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE; @@ -190,6 +194,8 @@ CREATE TABLE public.dnd_match_exercises ( description text NOT NULL ); +CREATE INDEX dnd_match_exercises_search_fts_idx ON public.dnd_match_exercises USING gin (to_tsvector('simple'::regconfig, ((COALESCE(title, ''::text) || ' '::text) || COALESCE(description, ''::text)))); + ALTER TABLE public.dnd_match_exercises ADD CONSTRAINT dnd_match_exercises_created_by_fkey FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE; @@ -210,6 +216,8 @@ CREATE TABLE public.dnd_match_pairs ( CREATE INDEX dnd_match_pairs_exercise_order_idx ON public.dnd_match_pairs USING btree (dnd_match_exercise_id, pair_order); +CREATE INDEX dnd_match_pairs_search_fts_idx ON public.dnd_match_pairs USING gin (to_tsvector('simple'::regconfig, ((COALESCE(left_item, ''::text) || ' '::text) || COALESCE(right_item, ''::text)))); + ALTER TABLE public.dnd_match_pairs ADD CONSTRAINT dnd_match_pairs_dnd_match_exercise_id_pair_order_key UNIQUE (dnd_match_exercise_id, pair_order); @@ -378,6 +386,8 @@ CREATE TABLE public.fill_gap_gaps ( gap_order integer NOT NULL ); +CREATE INDEX fill_gap_gaps_search_fts_idx ON public.fill_gap_gaps USING gin (to_tsvector('simple'::regconfig, COALESCE(token_text, ''::text))); + ALTER TABLE public.fill_gap_gaps ADD CONSTRAINT fill_gap_gaps_fill_gap_exercise_id_token_index_key UNIQUE (fill_gap_exercise_id, token_index); @@ -396,6 +406,8 @@ CREATE TABLE public.fill_gap_exercises ( source_html text NOT NULL DEFAULT ''::text ); +CREATE INDEX fill_gap_exercises_search_fts_idx ON public.fill_gap_exercises USING gin (to_tsvector('simple'::regconfig, ((((COALESCE(title, ''::text) || ' '::text) || COALESCE(source_text, ''::text)) || ' '::text) || COALESCE(source_html, ''::text)))); + ALTER TABLE public.fill_gap_exercises ADD CONSTRAINT fill_gap_exercises_exercise_id_fkey FOREIGN KEY (exercise_id) REFERENCES exercises(id) ON DELETE CASCADE; @@ -438,6 +450,8 @@ CREATE TABLE public.jumbled_sentence_sentences ( incorrect_alternates text[] NOT NULL DEFAULT ARRAY[]::text[] ); +CREATE INDEX jumbled_sentence_sentences_search_fts_idx ON public.jumbled_sentence_sentences USING gin (to_tsvector('simple'::regconfig, COALESCE(sentence, ''::text))); + CREATE TABLE public.jumbled_sentence_exercises ( id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, created_at timestamp with time zone NOT NULL DEFAULT now(), @@ -447,6 +461,8 @@ CREATE TABLE public.jumbled_sentence_exercises ( title text NOT NULL ); +CREATE INDEX jumbled_sentence_exercises_search_fts_idx ON public.jumbled_sentence_exercises USING gin (to_tsvector('simple'::regconfig, COALESCE(title, ''::text))); + ALTER TABLE public.jumbled_sentence_sentences ADD CONSTRAINT fk_jumbled_exercise FOREIGN KEY (jumbled_exercise_id) REFERENCES jumbled_sentence_exercises(id) ON DELETE CASCADE; @@ -509,6 +525,8 @@ CREATE TABLE public.free_form_exercises ( title text NOT NULL ); +CREATE INDEX free_form_exercises_search_fts_idx ON public.free_form_exercises USING gin (to_tsvector('simple'::regconfig, COALESCE(title, ''::text))); + ALTER TABLE public.free_form_answers ADD CONSTRAINT free_form_answers_free_form_exercise_id_fkey FOREIGN KEY (free_form_exercise_id) REFERENCES free_form_exercises(id) ON DELETE CASCADE; @@ -522,6 +540,8 @@ CREATE TABLE public.free_form_questions ( question_order integer NOT NULL DEFAULT 1 ); +CREATE INDEX free_form_questions_search_fts_idx ON public.free_form_questions USING gin (to_tsvector('simple'::regconfig, COALESCE(question, ''::text))); + ALTER TABLE public.free_form_answers ADD CONSTRAINT free_form_answers_free_form_question_id_fkey FOREIGN KEY (free_form_question_id) REFERENCES free_form_questions(id) ON DELETE CASCADE; @@ -599,6 +619,8 @@ CREATE TABLE public.html_pages ( updated_by bigint ); +CREATE INDEX html_pages_search_fts_idx ON public.html_pages USING gin (to_tsvector('simple'::regconfig, ((((COALESCE(title, ''::text) || ' '::text) || COALESCE(description, ''::text)) || ' '::text) || COALESCE(content, ''::text)))); + CREATE TRIGGER update_html_pages_updated_at BEFORE UPDATE ON public.html_pages FOR EACH ROW EXECUTE FUNCTION updated_at(); ALTER TABLE public.html_pages @@ -627,6 +649,8 @@ CREATE TABLE public.memory_game_exercises ( description text NOT NULL ); +CREATE INDEX memory_game_exercises_search_fts_idx ON public.memory_game_exercises USING gin (to_tsvector('simple'::regconfig, ((COALESCE(title, ''::text) || ' '::text) || COALESCE(description, ''::text)))); + ALTER TABLE public.memory_game_exercises ADD CONSTRAINT memory_game_exercises_created_by_fkey FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE; @@ -647,6 +671,8 @@ CREATE TABLE public.memory_game_pairs ( CREATE INDEX memory_game_pairs_exercise_order_idx ON public.memory_game_pairs USING btree (memory_game_exercise_id, pair_order); +CREATE INDEX memory_game_pairs_search_fts_idx ON public.memory_game_pairs USING gin (to_tsvector('simple'::regconfig, ((COALESCE(left_item, ''::text) || ' '::text) || COALESCE(right_item, ''::text)))); + ALTER TABLE public.memory_game_pairs ADD CONSTRAINT memory_game_pairs_memory_game_exercise_id_pair_order_key UNIQUE (memory_game_exercise_id, pair_order); @@ -695,6 +721,8 @@ CREATE TABLE public.multichoice_content ( updated_at timestamp with time zone NOT NULL DEFAULT now() ); +CREATE INDEX multichoice_content_search_fts_idx ON public.multichoice_content USING gin (to_tsvector('simple'::regconfig, ((COALESCE(content_value, ''::text) || ' '::text) || COALESCE(correct_answer, ''::text)))); + CREATE TABLE public.multichoice_exercises ( id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, exercise_id bigint NOT NULL, @@ -704,6 +732,8 @@ CREATE TABLE public.multichoice_exercises ( updated_at timestamp with time zone NOT NULL DEFAULT now() ); +CREATE INDEX multichoice_exercises_search_fts_idx ON public.multichoice_exercises USING gin (to_tsvector('simple'::regconfig, ((COALESCE(title, ''::text) || ' '::text) || COALESCE(exercise_description, ''::text)))); + ALTER TABLE public.multichoice_content ADD CONSTRAINT multichoice_content_multichoice_exercise_id_fkey FOREIGN KEY (multichoice_exercise_id) REFERENCES multichoice_exercises(id) ON DELETE CASCADE; diff --git a/gradesa/playwright-report/index.html b/gradesa/playwright-report/index.html index 1e25dce..a3682a8 100644 --- a/gradesa/playwright-report/index.html +++ b/gradesa/playwright-report/index.html @@ -82,4 +82,4 @@ Error generating stack: `+n.message+`
- \ No newline at end of file + \ No newline at end of file diff --git a/gradesa/test-results/.last-run.json b/gradesa/test-results/.last-run.json index 4cff7f2..b557150 100644 --- a/gradesa/test-results/.last-run.json +++ b/gradesa/test-results/.last-run.json @@ -1,11 +1,13 @@ { "status": "failed", "failedTests": [ + "e05c51b8ad1b3eb66010-0e43830ad8f2dfd8d1e2", + "c5b6e4261f23dff4104e-cb5330f948ccf9c8b61e", + "c5b6e4261f23dff4104e-fd730098ea5d4ab30d2a", + "d5ed79a6b333c2ba7209-ea64ca5a0854b7439e18", + "d5ed79a6b333c2ba7209-3a1aa6a9369793a93f4b", + "c5b6e4261f23dff4104e-4c06fad2b2a291767cec", "18e1443b7169cebccd21-4a0da125f055d790cf05", - "cf4ffee829137744e3cd-e6406448e73a28c0ddd9", - "d936625e1207b3e19d4b-67eb4c2dd9e8efb88e3d", - "d8918302922cfb4b5ab2-53975d1f9ee0854667fa", - "d8918302922cfb4b5ab2-fdd621e8f42178e15eb4", - "d8918302922cfb4b5ab2-ae27decdc4c0ad5570ee" + "d8918302922cfb4b5ab2-53975d1f9ee0854667fa" ] } \ No newline at end of file