From dfe68d5924d37ea4d3fd0df0a8e68871bcd187d5 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 2 Aug 2020 10:27:50 +0200 Subject: [PATCH] feat: migrate indexes --- src/Model/Migration.hs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Model/Migration.hs b/src/Model/Migration.hs index 6888a16a7..df6289f1f 100644 --- a/src/Model/Migration.hs +++ b/src/Model/Migration.hs @@ -71,6 +71,7 @@ migrateAll' :: Migration migrateAll' = sequence_ [ migrateUniWorX , migrateMemcachedSqlStorage + , migrateManual ] migrateAll :: ( MonadLogger m @@ -137,6 +138,27 @@ getMissingMigrations = do appliedMigrations <- selectKeysList [] [] return $ customMigrations `Map.withoutKeys` Set.fromList appliedMigrations + +migrateManual :: Migration +migrateManual = + addMigrations + [ (False, "CREATE INDEX IF NOT EXISTS course_application_file_content ON course_application_file (content)") + , (False, "CREATE INDEX IF NOT EXISTS material_file_content ON material_file (content)") + , (False, "CREATE INDEX IF NOT EXISTS course_news_file_content ON course_news_file (content)") + , (False, "CREATE INDEX IF NOT EXISTS sheet_file_content ON sheet_file (content)") + , (False, "CREATE INDEX IF NOT EXISTS course_app_instruction_file_content ON course_app_instruction_file (content)") + , (False, "CREATE INDEX IF NOT EXISTS allocation_matching_log ON allocation_matching (log)") + , (False, "CREATE INDEX IF NOT EXISTS submission_file_content ON submission_file (content)") + , (False, "CREATE INDEX IF NOT EXISTS session_file_content ON session_file (content)") + , (False, "CREATE INDEX IF NOT EXISTS file_lock_content ON file_lock (content)") + , (False, "CREATE INDEX IF NOT EXISTS user_lower_display_email ON \"user\" (lower(display_email))") + , (False, "CREATE INDEX IF NOT EXISTS user_lower_email ON \"user\" (lower(email))") + , (False, "CREATE INDEX IF NOT EXISTS user_lower_ident ON \"user\" (lower(ident))") + , (False, "CREATE INDEX IF NOT EXISTS submission_sheet ON submission (sheet)") + , (False, "CREATE INDEX IF NOT EXISTS submission_edit_submission ON submission_edit (submission)") + ] + + {- Confusion about quotes, from the PostgreSQL Manual: Single quotes for string constants, double quotes for table/column names. @@ -145,7 +167,6 @@ getMissingMigrations = do #{anything} (escaped as value); -} - customMigrations :: forall m. MonadResource m => Map (Key AppliedMigration) (ReaderT SqlBackend m ())