From 5ddf9cd44357f220f01ecaf43e66c258d9dee30e Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sat, 15 Apr 2023 00:44:19 +0300 Subject: [PATCH] don't skip temp indexes migration if the indexes column is already created --- migrations/1679943781_add_indexes_column.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/migrations/1679943781_add_indexes_column.go b/migrations/1679943781_add_indexes_column.go index 597a803e..96b1039b 100644 --- a/migrations/1679943781_add_indexes_column.go +++ b/migrations/1679943781_add_indexes_column.go @@ -42,14 +42,19 @@ func init() { return err } + var hasIndexesColumn bool for _, col := range cols { if col == "indexes" { - return nil // already existing (probably via the init migration) + // already existing (probably via the init migration) + hasIndexesColumn = true + break } } - if _, err := db.AddColumn("_collections", "indexes", `JSON DEFAULT "[]" NOT NULL`).Execute(); err != nil { - return err + if !hasIndexesColumn { + if _, err := db.AddColumn("_collections", "indexes", `JSON DEFAULT "[]" NOT NULL`).Execute(); err != nil { + return err + } } collections := []*models.Collection{}