Commit 85260257 by Torkel Ödegaard

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

parent d92fae07
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
**Fixes** **Fixes**
- [Issue #1857](https://github.com/grafana/grafana/issues/1857). /api/login/ping Fix for issue when behind reverse proxy and subpath - [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) # 2.0.2 (2015-04-22)
......
...@@ -14,9 +14,9 @@ import ( ...@@ -14,9 +14,9 @@ import (
func InitTestDB(t *testing.T) { func InitTestDB(t *testing.T) {
t.Log("InitTestDB") 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_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 { if err != nil {
t.Fatalf("Failed to init in memory sqllite3 db %v", err) t.Fatalf("Failed to init in memory sqllite3 db %v", err)
......
...@@ -86,4 +86,10 @@ func addDashboardMigration(mg *Migrator) { ...@@ -86,4 +86,10 @@ func addDashboardMigration(mg *Migrator) {
})) }))
mg.AddMigration("drop table dashboard_v1", NewDropTableMigration("dashboard_v1")) 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;"))
} }
...@@ -48,4 +48,10 @@ func addDashboardSnapshotMigrations(mg *Migrator) { ...@@ -48,4 +48,10 @@ func addDashboardSnapshotMigrations(mg *Migrator) {
mg.AddMigration("create dashboard_snapshot table v5 #2", NewAddTableMigration(snapshotV5)) mg.AddMigration("create dashboard_snapshot table v5 #2", NewAddTableMigration(snapshotV5))
addTableIndicesMigrations(mg, "v5", 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;"))
} }
...@@ -27,6 +27,7 @@ type RawSqlMigration struct { ...@@ -27,6 +27,7 @@ type RawSqlMigration struct {
sqlite string sqlite string
mysql string mysql string
postgres string
} }
func (m *RawSqlMigration) Sql(dialect Dialect) string { func (m *RawSqlMigration) Sql(dialect Dialect) string {
...@@ -35,6 +36,8 @@ func (m *RawSqlMigration) Sql(dialect Dialect) string { ...@@ -35,6 +36,8 @@ func (m *RawSqlMigration) Sql(dialect Dialect) string {
return m.mysql return m.mysql
case SQLITE: case SQLITE:
return m.sqlite return m.sqlite
case POSTGRES:
return m.postgres
} }
panic("db type not supported") panic("db type not supported")
...@@ -50,6 +53,11 @@ func (m *RawSqlMigration) Mysql(sql string) *RawSqlMigration { ...@@ -50,6 +53,11 @@ func (m *RawSqlMigration) Mysql(sql string) *RawSqlMigration {
return m return m
} }
func (m *RawSqlMigration) Postgres(sql string) *RawSqlMigration {
m.postgres = sql
return m
}
type AddColumnMigration struct { type AddColumnMigration struct {
MigrationBase MigrationBase
tableName string tableName string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment