mirror of https://github.com/grafana/grafana
Live: Remove dev code that would save config and messages in SQL (#62912)
parent
84a6671911
commit
72790b0614
@ -1,50 +0,0 @@ |
|||||||
package export |
|
||||||
|
|
||||||
import ( |
|
||||||
"fmt" |
|
||||||
"path" |
|
||||||
"time" |
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/db" |
|
||||||
) |
|
||||||
|
|
||||||
func exportLive(helper *commitHelper, job *gitExportJob) error { |
|
||||||
messagedir := path.Join(helper.orgDir, "system", "live", "message") |
|
||||||
|
|
||||||
return job.sql.WithDbSession(helper.ctx, func(sess *db.Session) error { |
|
||||||
type msgResult struct { |
|
||||||
Channel string `xorm:"channel"` |
|
||||||
Data string `xorm:"data"` |
|
||||||
CreatedBy int64 `xorm:"created_by"` |
|
||||||
Created time.Time `xorm:"created"` |
|
||||||
} |
|
||||||
|
|
||||||
rows := make([]*msgResult, 0) |
|
||||||
|
|
||||||
sess.Table("live_message").Where("org_id = ?", helper.orgID) |
|
||||||
|
|
||||||
err := sess.Find(&rows) |
|
||||||
if err != nil { |
|
||||||
if isTableNotExistsError(err) { |
|
||||||
return nil |
|
||||||
} |
|
||||||
return err |
|
||||||
} |
|
||||||
|
|
||||||
for _, row := range rows { |
|
||||||
err = helper.add(commitOptions{ |
|
||||||
body: []commitBody{{ |
|
||||||
body: []byte(row.Data), |
|
||||||
fpath: path.Join(messagedir, row.Channel) + ".json", // must be JSON files
|
|
||||||
}}, |
|
||||||
comment: fmt.Sprintf("Exporting: %s", row.Channel), |
|
||||||
when: row.Created, |
|
||||||
userID: row.CreatedBy, |
|
||||||
}) |
|
||||||
if err != nil { |
|
||||||
return err |
|
||||||
} |
|
||||||
} |
|
||||||
return err |
|
||||||
}) |
|
||||||
} |
|
@ -1,24 +0,0 @@ |
|||||||
package migrations |
|
||||||
|
|
||||||
import "github.com/grafana/grafana/pkg/services/sqlstore/migrator" |
|
||||||
|
|
||||||
// For now disable migration. For now we are using local cache as storage to evaluate ideas.
|
|
||||||
// This will be turned on soon though.
|
|
||||||
func addLiveChannelMigrations(mg *migrator.Migrator) { |
|
||||||
//liveMessage := migrator.Table{
|
|
||||||
// Name: "live_message",
|
|
||||||
// Columns: []*migrator.Column{
|
|
||||||
// {Name: "id", Type: migrator.DB_BigInt, Nullable: false, IsPrimaryKey: true, IsAutoIncrement: true},
|
|
||||||
// {Name: "org_id", Type: migrator.DB_BigInt, Nullable: false},
|
|
||||||
// {Name: "channel", Type: migrator.DB_NVarchar, Length: 189, Nullable: false},
|
|
||||||
// {Name: "data", Type: migrator.DB_Text, Nullable: false},
|
|
||||||
// {Name: "published", Type: migrator.DB_DateTime, Nullable: false},
|
|
||||||
// },
|
|
||||||
// Indices: []*migrator.Index{
|
|
||||||
// {Cols: []string{"org_id", "channel"}, Type: migrator.UniqueIndex},
|
|
||||||
// },
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//mg.AddMigration("create live message table", migrator.NewAddTableMigration(liveMessage))
|
|
||||||
//mg.AddMigration("add index live_message.org_id_channel_unique", migrator.NewAddIndexMigration(liveMessage, liveMessage.Indices[0]))
|
|
||||||
} |
|
Loading…
Reference in new issue