diff --git a/pkg/services/sqlstore/migrations/dashboard_mig.go b/pkg/services/sqlstore/migrations/dashboard_mig.go index 5d440d85ebc..66ad02ba27d 100644 --- a/pkg/services/sqlstore/migrations/dashboard_mig.go +++ b/pkg/services/sqlstore/migrations/dashboard_mig.go @@ -92,4 +92,14 @@ func addDashboardMigration(mg *Migrator) { Sqlite("SELECT 0 WHERE 0;"). Postgres("SELECT 0;"). Mysql("ALTER TABLE dashboard MODIFY data MEDIUMTEXT;")) + + // add column to store creator of a dashboard + mg.AddMigration("Add column created_by", NewAddColumnMigration(dashboardV2, &Column{ + Name: "created_by", Type: DB_BigInt, Nullable: true, + })) + + // add column to store updater of a dashboard + mg.AddMigration("Add column updated_by", NewAddColumnMigration(dashboardV2, &Column{ + Name: "updated_by", Type: DB_BigInt, Nullable: true, + })) } diff --git a/pkg/services/sqlstore/migrator/migrations.go b/pkg/services/sqlstore/migrator/migrations.go index a65c7ec7e81..26387fcb7db 100644 --- a/pkg/services/sqlstore/migrator/migrations.go +++ b/pkg/services/sqlstore/migrator/migrations.go @@ -64,6 +64,10 @@ type AddColumnMigration struct { column *Column } +func NewAddColumnMigration(table Table, col *Column) *AddColumnMigration { + return &AddColumnMigration{tableName: table.Name, column: col} +} + func (m *AddColumnMigration) Table(tableName string) *AddColumnMigration { m.tableName = tableName return m