mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Query history: Create API to add query to query history (#44479)
* Create config to enable/disable query history * Create add to query history functionality * Add documentation * Add test * Refactor * Add test * Fix built errors and linting errors * Refactor * Remove old tests * Refactor, adjust based on feedback, add new test * Update default value
This commit is contained in:
@@ -68,6 +68,7 @@ func (*OSSMigrations) AddMigration(mg *Migrator) {
|
||||
addKVStoreMigrations(mg)
|
||||
ualert.AddDashboardUIDPanelIDMigration(mg)
|
||||
accesscontrol.AddMigration(mg)
|
||||
addQueryHistoryMigrations(mg)
|
||||
}
|
||||
|
||||
func addMigrationLogMigrations(mg *Migrator) {
|
||||
|
||||
28
pkg/services/sqlstore/migrations/query_history_mig.go
Normal file
28
pkg/services/sqlstore/migrations/query_history_mig.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
)
|
||||
|
||||
func addQueryHistoryMigrations(mg *Migrator) {
|
||||
queryHistoryV1 := Table{
|
||||
Name: "query_history",
|
||||
Columns: []*Column{
|
||||
{Name: "id", Type: DB_BigInt, Nullable: false, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
{Name: "uid", Type: DB_NVarchar, Length: 40, Nullable: false},
|
||||
{Name: "org_id", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "datasource_uid", Type: DB_NVarchar, Length: 40, Nullable: false},
|
||||
{Name: "created_by", Type: DB_Int, Nullable: false},
|
||||
{Name: "created_at", Type: DB_Int, Nullable: false},
|
||||
{Name: "comment", Type: DB_Text, Nullable: false},
|
||||
{Name: "queries", Type: DB_Text, Nullable: false},
|
||||
},
|
||||
Indices: []*Index{
|
||||
{Cols: []string{"org_id", "created_by", "datasource_uid"}},
|
||||
},
|
||||
}
|
||||
|
||||
mg.AddMigration("create query_history table v1", NewAddTableMigration(queryHistoryV1))
|
||||
|
||||
mg.AddMigration("add index query_history.org_id-created_by-datasource_uid", NewAddIndexMigration(queryHistoryV1, queryHistoryV1.Indices[0]))
|
||||
}
|
||||
Reference in New Issue
Block a user