40 Star 146 Fork 3

Gitee 极速下载/grafana

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/grafana/grafana
克隆/下载
stats_mig.go 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
package migrations
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
func addStatsMigrations(mg *Migrator) {
statTable := Table{
Name: "stat",
Columns: []*Column{
{Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "metric", Type: DB_Varchar, Length: 20, Nullable: false},
{Name: "type", Type: DB_Int, Nullable: false},
},
Indices: []*Index{
{Cols: []string{"metric"}, Type: UniqueIndex},
},
}
// create table
mg.AddMigration("create stat table", NewAddTableMigration(statTable))
// create indices
mg.AddMigration("add index stat.metric", NewAddIndexMigration(statTable, statTable.Indices[0]))
statValue := Table{
Name: "stat_value",
Columns: []*Column{
{Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "value", Type: DB_Double, Nullable: false},
{Name: "time", Type: DB_DateTime, Nullable: false},
},
}
// create table
mg.AddMigration("create stat_value table", NewAddTableMigration(statValue))
}
func addTestDataMigrations(mg *Migrator) {
testData := Table{
Name: "test_data",
Columns: []*Column{
{Name: "id", Type: DB_Int, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "metric1", Type: DB_Varchar, Length: 20, Nullable: true},
{Name: "metric2", Type: DB_NVarchar, Length: 150, Nullable: true},
{Name: "value_big_int", Type: DB_BigInt, Nullable: true},
{Name: "value_double", Type: DB_Double, Nullable: true},
{Name: "value_float", Type: DB_Float, Nullable: true},
{Name: "value_int", Type: DB_Int, Nullable: true},
{Name: "time_epoch", Type: DB_BigInt, Nullable: false},
{Name: "time_date_time", Type: DB_DateTime, Nullable: false},
{Name: "time_time_stamp", Type: DB_TimeStamp, Nullable: false},
},
}
// create table
mg.AddMigration("create test_data table", NewAddTableMigration(testData))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/grafana.git
git@gitee.com:mirrors/grafana.git
mirrors
grafana
grafana
v5.1.2

搜索帮助

0d507c66 1850385 C8b1a773 1850385