mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 01:33:59 +00:00
load db structure progress (postgresql) #273
This commit is contained in:
@@ -15,6 +15,7 @@ let afterConnectCallbacks = [];
|
|||||||
let afterAnalyseCallbacks = [];
|
let afterAnalyseCallbacks = [];
|
||||||
let analysedStructure = null;
|
let analysedStructure = null;
|
||||||
let lastPing = null;
|
let lastPing = null;
|
||||||
|
let lastStatusString = null;
|
||||||
let lastStatus = null;
|
let lastStatus = null;
|
||||||
let analysedTime = 0;
|
let analysedTime = 0;
|
||||||
let serverVersion;
|
let serverVersion;
|
||||||
@@ -84,15 +85,17 @@ function handleSyncModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setStatus(status) {
|
function setStatus(status) {
|
||||||
const statusString = stableStringify(status);
|
const newStatus = { ...lastStatus, ...status };
|
||||||
if (lastStatus != statusString) {
|
const statusString = stableStringify(newStatus);
|
||||||
process.send({ msgtype: 'status', status: { ...status, counter: getStatusCounter() } });
|
if (lastStatusString != statusString) {
|
||||||
lastStatus = statusString;
|
process.send({ msgtype: 'status', status: { ...newStatus, counter: getStatusCounter() } });
|
||||||
|
lastStatusString = statusString;
|
||||||
|
lastStatus = newStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatusName(name) {
|
function setStatusName(name) {
|
||||||
setStatus({ name });
|
setStatus({ name, message: null });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readVersion() {
|
async function readVersion() {
|
||||||
@@ -109,6 +112,7 @@ async function handleConnect({ connection, structure, globalSettings }) {
|
|||||||
if (!structure) setStatusName('pending');
|
if (!structure) setStatusName('pending');
|
||||||
const driver = requireEngineDriver(storedConnection);
|
const driver = requireEngineDriver(storedConnection);
|
||||||
systemConnection = await checkedAsyncCall(connectUtility(driver, storedConnection, 'app'));
|
systemConnection = await checkedAsyncCall(connectUtility(driver, storedConnection, 'app'));
|
||||||
|
systemConnection.feedback = feedback => setStatus({ feedback });
|
||||||
await checkedAsyncCall(readVersion());
|
await checkedAsyncCall(readVersion());
|
||||||
if (structure) {
|
if (structure) {
|
||||||
analysedStructure = structure;
|
analysedStructure = structure;
|
||||||
|
|||||||
@@ -220,6 +220,12 @@ export class DatabaseAnalyser {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
feedback(obj) {
|
||||||
|
if (this.pool.feedback) {
|
||||||
|
this.pool.feedback(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getModifications() {
|
async getModifications() {
|
||||||
const snapshot = await this._getFastSnapshot();
|
const snapshot = await this._getFastSnapshot();
|
||||||
if (!snapshot) return null;
|
if (!snapshot) return null;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
objectTypeField: 'queries',
|
objectTypeField: 'queries',
|
||||||
pureName: query.name,
|
pureName: query.name,
|
||||||
schemaName: app.name,
|
schemaName: app.name,
|
||||||
sql: query.sql
|
sql: query.sql,
|
||||||
}))
|
}))
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
</SearchBoxWrapper>
|
</SearchBoxWrapper>
|
||||||
<WidgetsInnerContainer>
|
<WidgetsInnerContainer>
|
||||||
{#if ($status && ($status.name == 'pending' || $status.name == 'checkStructure' || $status.name == 'loadStructure') && $objects) || !$objects}
|
{#if ($status && ($status.name == 'pending' || $status.name == 'checkStructure' || $status.name == 'loadStructure') && $objects) || !$objects}
|
||||||
<LoadingInfo message="Loading database structure" />
|
<LoadingInfo message={$status?.feedback?.analysingMessage || 'Loading database structure'} />
|
||||||
{:else}
|
{:else}
|
||||||
<AppObjectList
|
<AppObjectList
|
||||||
list={objectList.map(x => ({ ...x, conid, database }))}
|
list={objectList.map(x => ({ ...x, conid, database }))}
|
||||||
|
|||||||
@@ -52,28 +52,40 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _runAnalysis() {
|
async _runAnalysis() {
|
||||||
|
this.feedback({ analysingMessage: 'Loading tables' });
|
||||||
const tables = await this.driver.query(
|
const tables = await this.driver.query(
|
||||||
this.pool,
|
this.pool,
|
||||||
this.createQuery(this.driver.dialect.stringAgg ? 'tableModifications' : 'tableList', ['tables'])
|
this.createQuery(this.driver.dialect.stringAgg ? 'tableModifications' : 'tableList', ['tables'])
|
||||||
);
|
);
|
||||||
|
this.feedback({ analysingMessage: 'Loading columns' });
|
||||||
const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables', 'views']));
|
const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables', 'views']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading primary keys' });
|
||||||
const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables']));
|
const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading foreign keys' });
|
||||||
const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables']));
|
const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading views' });
|
||||||
const views = await this.driver.query(this.pool, this.createQuery('views', ['views']));
|
const views = await this.driver.query(this.pool, this.createQuery('views', ['views']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading materialized views' });
|
||||||
const matviews = this.driver.dialect.materializedViews
|
const matviews = this.driver.dialect.materializedViews
|
||||||
? await this.driver.query(this.pool, this.createQuery('matviews', ['matviews']))
|
? await this.driver.query(this.pool, this.createQuery('matviews', ['matviews']))
|
||||||
: null;
|
: null;
|
||||||
|
this.feedback({ analysingMessage: 'Loading materialized view columns' });
|
||||||
const matviewColumns = this.driver.dialect.materializedViews
|
const matviewColumns = this.driver.dialect.materializedViews
|
||||||
? await this.driver.query(this.pool, this.createQuery('matviewColumns', ['matviews']))
|
? await this.driver.query(this.pool, this.createQuery('matviewColumns', ['matviews']))
|
||||||
: null;
|
: null;
|
||||||
|
this.feedback({ analysingMessage: 'Loading routines' });
|
||||||
const routines = await this.driver.query(this.pool, this.createQuery('routines', ['procedures', 'functions']));
|
const routines = await this.driver.query(this.pool, this.createQuery('routines', ['procedures', 'functions']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading indexes' });
|
||||||
const indexes = this.driver.__analyserInternals.skipIndexes
|
const indexes = this.driver.__analyserInternals.skipIndexes
|
||||||
? { rows: [] }
|
? { rows: [] }
|
||||||
: await this.driver.query(this.pool, this.createQuery('indexes', ['tables']));
|
: await this.driver.query(this.pool, this.createQuery('indexes', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading index columns' });
|
||||||
const indexcols = this.driver.__analyserInternals.skipIndexes
|
const indexcols = this.driver.__analyserInternals.skipIndexes
|
||||||
? { rows: [] }
|
? { rows: [] }
|
||||||
: await this.driver.query(this.pool, this.createQuery('indexcols', ['tables']));
|
: await this.driver.query(this.pool, this.createQuery('indexcols', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading unique names' });
|
||||||
const uniqueNames = await this.driver.query(this.pool, this.createQuery('uniqueNames', ['tables']));
|
const uniqueNames = await this.driver.query(this.pool, this.createQuery('uniqueNames', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: null });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tables: tables.rows.map(table => {
|
tables: tables.rows.map(table => {
|
||||||
|
|||||||
Reference in New Issue
Block a user