mysql: minor update

This commit is contained in:
Torkel Ödegaard
2017-03-30 20:23:40 +02:00
parent 998f04e1e8
commit bd4f073425
5 changed files with 24 additions and 4 deletions

View File

@@ -41,7 +41,7 @@ func addTestDataMigrations(mg *Migrator) {
{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_ing", Type: DB_BigInt, 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},

View File

@@ -1,6 +1,8 @@
package sqlstore
import (
"time"
"github.com/grafana/grafana/pkg/bus"
m "github.com/grafana/grafana/pkg/models"
)
@@ -12,10 +14,17 @@ func init() {
func InsertSqlTestData(cmd *m.InsertSqlTestDataCommand) error {
return inTransaction2(func(sess *session) error {
// create user
user := &m.SqlTestData{}
row := &m.SqlTestData{
Metric1: "server1",
Metric2: "frontend",
ValueBigInt: 123123,
ValueDouble: 3.14159265359,
ValueFloat: 3.14159265359,
TimeEpoch: time.Now().Unix(),
TimeDateTime: time.Now(),
}
if _, err := sess.Insert(user); err != nil {
if _, err := sess.Table("test_data").Insert(row); err != nil {
return err
}