add key/value store service (#36868)
* add key/value store service * don't export kvStoreSQL, consumers should interact with KVStore & NamespacedKVStore * add del method, avoid ErrNotFound (#38627) * switch value column to medium text Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
This commit is contained in:
co-authored by
Alexander Emelin
parent
dd24995852
commit
681de1ea89
@@ -0,0 +1,27 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
)
|
||||
|
||||
func addKVStoreMigrations(mg *Migrator) {
|
||||
kvStoreV1 := Table{
|
||||
Name: "kv_store",
|
||||
Columns: []*Column{
|
||||
{Name: "id", Type: DB_BigInt, Nullable: false, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
{Name: "org_id", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "namespace", Type: DB_NVarchar, Length: 190, Nullable: false},
|
||||
{Name: "key", Type: DB_NVarchar, Length: 190, Nullable: false},
|
||||
{Name: "value", Type: DB_MediumText, Nullable: false},
|
||||
{Name: "created", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "updated", Type: DB_DateTime, Nullable: false},
|
||||
},
|
||||
Indices: []*Index{
|
||||
{Cols: []string{"org_id", "namespace", "key"}, Type: UniqueIndex},
|
||||
},
|
||||
}
|
||||
|
||||
mg.AddMigration("create kv_store table v1", NewAddTableMigration(kvStoreV1))
|
||||
|
||||
mg.AddMigration("add index kv_store.org_id-namespace-key", NewAddIndexMigration(kvStoreV1, kvStoreV1.Indices[0]))
|
||||
}
|
||||
@@ -52,6 +52,7 @@ func (*OSSMigrations) AddMigration(mg *Migrator) {
|
||||
addLiveChannelMigrations(mg)
|
||||
}
|
||||
ualert.RerunDashAlertMigration(mg)
|
||||
addKVStoreMigrations(mg)
|
||||
}
|
||||
|
||||
func addMigrationLogMigrations(mg *Migrator) {
|
||||
|
||||
Reference in New Issue
Block a user