From 4248caadf0ecb7c570dbd9dd3e6e7e6aeeeee3df Mon Sep 17 00:00:00 2001 From: apiraino Date: Fri, 19 Apr 2024 16:38:04 +0200 Subject: [PATCH] Fix DB schema migrations - Fix a wrong migration introduced in #1781 - Clarify how DB migrations should be added to the triagebot --- src/db.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/db.rs b/src/db.rs index 1da96372..35945f11 100644 --- a/src/db.rs +++ b/src/db.rs @@ -272,6 +272,9 @@ async fn handle_job( Ok(()) } +// Important notes when adding migrations: +// - Each DB change is an element in this array and must be a single SQL instruction +// - The total # of items in this array must be equal to the value of `database_versions.migration_counter` static MIGRATIONS: &[&str] = &[ " CREATE TABLE notifications ( @@ -332,7 +335,8 @@ CREATE table review_prefs ( assigned_prs INT[] NOT NULL DEFAULT array[]::INT[] );", " -CREATE EXTENSION intarray; -CREATE UNIQUE INDEX review_prefs_user_id ON review_prefs(user_id); +CREATE EXTENSION IF NOT EXISTS intarray;", + " +CREATE UNIQUE INDEX IF NOT EXISTS review_prefs_user_id ON review_prefs(user_id); ", ];