MySQL: Dashboard.data column type changed to mediumtext (sql migration added), Fixes #1863

This commit is contained in:
Torkel Ödegaard 2015-04-23 16:18:00 +02:00
parent d92fae07a5
commit 8526025792
5 changed files with 25 additions and 4 deletions

View File

@ -2,6 +2,7 @@
**Fixes**
- [Issue #1857](https://github.com/grafana/grafana/issues/1857). /api/login/ping Fix for issue when behind reverse proxy and subpath
- [Issue #1863](https://github.com/grafana/grafana/issues/1863). MySQL: Dashboard.data column type changed to mediumtext (sql migration added)
# 2.0.2 (2015-04-22)

View File

@ -14,9 +14,9 @@ import (
func InitTestDB(t *testing.T) {
t.Log("InitTestDB")
x, err := xorm.NewEngine(sqlutil.TestDB_Sqlite3.DriverName, sqlutil.TestDB_Sqlite3.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Sqlite3.DriverName, sqlutil.TestDB_Sqlite3.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Mysql.DriverName, sqlutil.TestDB_Mysql.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Postgres.DriverName, sqlutil.TestDB_Postgres.ConnStr)
x, err := xorm.NewEngine(sqlutil.TestDB_Postgres.DriverName, sqlutil.TestDB_Postgres.ConnStr)
if err != nil {
t.Fatalf("Failed to init in memory sqllite3 db %v", err)

View File

@ -86,4 +86,10 @@ func addDashboardMigration(mg *Migrator) {
}))
mg.AddMigration("drop table dashboard_v1", NewDropTableMigration("dashboard_v1"))
// change column type of dashboard.data
mg.AddMigration("alter dashboard.data to mediumtext v1", new(RawSqlMigration).
Sqlite("SELECT 0 WHERE 0;").
Postgres("SELECT 0;").
Mysql("ALTER TABLE dashboard MODIFY data MEDIUMTEXT;"))
}

View File

@ -48,4 +48,10 @@ func addDashboardSnapshotMigrations(mg *Migrator) {
mg.AddMigration("create dashboard_snapshot table v5 #2", NewAddTableMigration(snapshotV5))
addTableIndicesMigrations(mg, "v5", snapshotV5)
// ncrease data type
mg.AddMigration("alter dashboard_snapshot.data to mediumtext v1", new(RawSqlMigration).
Sqlite("SELECT 0 WHERE 0;").
Postgres("SELECT 0;").
Mysql("ALTER TABLE dashboard_snapshot.data MODIFY data MEDIUMTEXT;"))
}

View File

@ -25,8 +25,9 @@ func (m *MigrationBase) GetCondition() MigrationCondition {
type RawSqlMigration struct {
MigrationBase
sqlite string
mysql string
sqlite string
mysql string
postgres string
}
func (m *RawSqlMigration) Sql(dialect Dialect) string {
@ -35,6 +36,8 @@ func (m *RawSqlMigration) Sql(dialect Dialect) string {
return m.mysql
case SQLITE:
return m.sqlite
case POSTGRES:
return m.postgres
}
panic("db type not supported")
@ -50,6 +53,11 @@ func (m *RawSqlMigration) Mysql(sql string) *RawSqlMigration {
return m
}
func (m *RawSqlMigration) Postgres(sql string) *RawSqlMigration {
m.postgres = sql
return m
}
type AddColumnMigration struct {
MigrationBase
tableName string