From 38fc0c68e4ed4825eebaba182741e65f9c26a3b7 Mon Sep 17 00:00:00 2001 From: Jeff Levin Date: Tue, 3 May 2022 15:10:59 -0800 Subject: [PATCH] Update documentation to explicitly state we should not be putting migrations behind feature flags (#48663) --- contribute/architecture/backend/database.md | 2 ++ pkg/services/sqlstore/migrations/migrations.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/contribute/architecture/backend/database.md b/contribute/architecture/backend/database.md index 75f7a63704b..4d2700015bf 100644 --- a/contribute/architecture/backend/database.md +++ b/contribute/architecture/backend/database.md @@ -99,6 +99,8 @@ To add a migration: - In the `AddMigrations` function, find the `addXxxMigration` function for the service you want to create a migration for. - At the end of the `addXxxMigration` function, register your migration: +> **NOTE:** Putting migrations behind feature flags is no longer recommended as it may cause the migration skip integration testing. + [Example](https://github.com/grafana/grafana/blob/00d0640b6e778ddaca021670fe851fe00982acf2/pkg/services/sqlstore/migrations/migrations.go#L55-L70) ### Implement `DatabaseMigrator` diff --git a/pkg/services/sqlstore/migrations/migrations.go b/pkg/services/sqlstore/migrations/migrations.go index 32f287d8296..760c0172604 100644 --- a/pkg/services/sqlstore/migrations/migrations.go +++ b/pkg/services/sqlstore/migrations/migrations.go @@ -13,6 +13,9 @@ import ( // 1. Never change a migration that is committed and pushed to main // 2. Always add new migrations (to change or undo previous migrations) // 3. Some migrations are not yet written (rename column, table, drop table, index etc) +// 4. Putting migrations behind feature flags is no longer recommended as broken +// migrations may not be caught by integration tests unless feature flags are +// specifically added type OSSMigrations struct { }