mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 04:59:15 -06:00
autodetect timescaledb when version >= 9.6
This commit is contained in:
parent
2d12801186
commit
a2f4441f9d
@ -11,21 +11,27 @@ export class PostgresConfigCtrl {
|
||||
this.datasourceSrv = datasourceSrv;
|
||||
this.current.jsonData.sslmode = this.current.jsonData.sslmode || 'verify-full';
|
||||
this.current.jsonData.postgresVersion = this.current.jsonData.postgresVersion || 903;
|
||||
this.autoDetectPostgresVersion();
|
||||
this.autoDetectFeatures();
|
||||
}
|
||||
|
||||
autoDetectPostgresVersion() {
|
||||
autoDetectFeatures() {
|
||||
if (!this.current.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.datasourceSrv
|
||||
.loadDatasource(this.current.name)
|
||||
.then(ds => {
|
||||
return ds.getVersion();
|
||||
})
|
||||
.then(version => {
|
||||
this.datasourceSrv.loadDatasource(this.current.name).then(ds => {
|
||||
return ds.getVersion().then(version => {
|
||||
version = Number(version[0].text);
|
||||
|
||||
// timescaledb is only available for 9.6+
|
||||
if (version >= 906) {
|
||||
ds.getTimescaleDBVersion().then(version => {
|
||||
if (version.length === 1) {
|
||||
this.current.jsonData.timescaledb = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let major = Math.trunc(version / 100);
|
||||
let minor = version % 100;
|
||||
let name = String(major);
|
||||
@ -37,6 +43,7 @@ export class PostgresConfigCtrl {
|
||||
}
|
||||
this.current.jsonData.postgresVersion = version;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// the value portion is derived from postgres server_version_num/100
|
||||
|
@ -128,6 +128,10 @@ export class PostgresDatasource {
|
||||
return this.metricFindQuery("SELECT current_setting('server_version_num')::int/100", {});
|
||||
}
|
||||
|
||||
getTimescaleDBVersion() {
|
||||
return this.metricFindQuery("SELECT extversion FROM pg_extension WHERE extname = 'timescaledb'", {});
|
||||
}
|
||||
|
||||
testDatasource() {
|
||||
return this.metricFindQuery('SELECT 1', {})
|
||||
.then(res => {
|
||||
|
Loading…
Reference in New Issue
Block a user