Spanner support enhancements (#101634)
* Adds ability to run integration tests against spanner (by using GRAFANA_TEST_DB=spanner env variable. SPANNER_DB variable then specifies database to use: spannertest, emulator or string like /projects/<project>/instances/<instance>/databases/<db>) * Adds feature to migration dialects to create database from a snapshot, instead of running individual migrations. * Adds first version of Spanner snapshot, prepared from "OSS" migrations. * Uses generated bit-reversed-positive values instead of auto_increment. (As an experiment)
This commit is contained in:
@@ -6,8 +6,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/session"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/session"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
@@ -68,6 +69,10 @@ type Dialect interface {
|
||||
CleanDB(engine *xorm.Engine) error
|
||||
TruncateDBTables(engine *xorm.Engine) error
|
||||
NoOpSQL() string
|
||||
// CreateDatabaseFromSnapshot is called when migration log table is not found.
|
||||
// Dialect can recreate all tables from existing snapshot. After successful (nil error) return,
|
||||
// migrator will list migrations from the log, and apply all missing migrations.
|
||||
CreateDatabaseFromSnapshot(ctx context.Context, engine *xorm.Engine, migrationLogTableName string) error
|
||||
|
||||
IsUniqueConstraintViolation(err error) bool
|
||||
ErrorMessage(err error) string
|
||||
@@ -338,6 +343,10 @@ func (b *BaseDialect) CleanDB(engine *xorm.Engine) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *BaseDialect) CreateDatabaseFromSnapshot(ctx context.Context, engine *xorm.Engine, tableName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *BaseDialect) NoOpSQL() string {
|
||||
return "SELECT 0;"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user