mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Storage: make it work for Postgres (#79378)
* comment out cockroachdb connection config option that does not work for postgres * log the error instead
This commit is contained in:
parent
9bd20db49f
commit
88fe392f8b
@ -9,6 +9,7 @@ import (
|
|||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/db"
|
"github.com/grafana/grafana/pkg/infra/db"
|
||||||
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
|
|
||||||
// "github.com/grafana/grafana/pkg/services/sqlstore"
|
// "github.com/grafana/grafana/pkg/services/sqlstore"
|
||||||
@ -26,6 +27,7 @@ func ProvideEntityDB(db db.DB, cfg *setting.Cfg, features featuremgmt.FeatureTog
|
|||||||
db: db,
|
db: db,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
features: features,
|
features: features,
|
||||||
|
log: log.New("entity-db"),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ type EntityDB struct {
|
|||||||
features featuremgmt.FeatureToggles
|
features featuremgmt.FeatureToggles
|
||||||
engine *xorm.Engine
|
engine *xorm.Engine
|
||||||
cfg *setting.Cfg
|
cfg *setting.Cfg
|
||||||
|
log log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *EntityDB) Init() error {
|
func (db *EntityDB) Init() error {
|
||||||
@ -78,9 +81,11 @@ func (db *EntityDB) GetEngine() (*xorm.Engine, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this config option is cockroachdb-specific, it's not supported by postgres
|
||||||
_, err = engine.Exec("SET SESSION enable_experimental_alter_column_type_general=true")
|
_, err = engine.Exec("SET SESSION enable_experimental_alter_column_type_general=true")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
db.log.Error("error connecting to postgres", "msg", err.Error())
|
||||||
|
// FIXME: return nil, err
|
||||||
}
|
}
|
||||||
} else if dbType == "mysql" {
|
} else if dbType == "mysql" {
|
||||||
// TODO: support all mysql connection options
|
// TODO: support all mysql connection options
|
||||||
|
Loading…
Reference in New Issue
Block a user