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