mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 02:05:59 +00:00
mysql - analyse views, procedures, functions
This commit is contained in:
@@ -44,6 +44,8 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
|||||||
const columns = await this.driver.query(this.pool, this.createQuery('columns'));
|
const columns = await this.driver.query(this.pool, this.createQuery('columns'));
|
||||||
const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys'));
|
const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys'));
|
||||||
const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys'));
|
const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys'));
|
||||||
|
const views = await this.driver.query(this.pool, this.createQuery('views'));
|
||||||
|
const programmables = await this.driver.query(this.pool, this.createQuery('programmables'));
|
||||||
|
|
||||||
return this.mergeAnalyseResult({
|
return this.mergeAnalyseResult({
|
||||||
tables: tables.rows.map((table) => ({
|
tables: tables.rows.map((table) => ({
|
||||||
@@ -52,6 +54,12 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
|||||||
primaryKey: DatabaseAnalayser.extractPrimaryKeys(table, pkColumns.rows),
|
primaryKey: DatabaseAnalayser.extractPrimaryKeys(table, pkColumns.rows),
|
||||||
foreignKeys: DatabaseAnalayser.extractForeignKeys(table, fkColumns.rows),
|
foreignKeys: DatabaseAnalayser.extractForeignKeys(table, fkColumns.rows),
|
||||||
})),
|
})),
|
||||||
|
views: views.rows.map((view) => ({
|
||||||
|
...view,
|
||||||
|
columns: columns.rows.filter((col) => col.pureName == view.pureName).map(getColumnInfo),
|
||||||
|
})),
|
||||||
|
procedures: programmables.rows.filter((x) => x.objectType == 'PROCEDURE').map(fp.omit(['objectType'])),
|
||||||
|
functions: programmables.rows.filter((x) => x.objectType == 'FUNCTION').map(fp.omit(['objectType'])),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ const tables = require('./tables');
|
|||||||
const primaryKeys = require('./primaryKeys');
|
const primaryKeys = require('./primaryKeys');
|
||||||
const foreignKeys = require('./foreignKeys');
|
const foreignKeys = require('./foreignKeys');
|
||||||
const tableModifications = require('./tableModifications');
|
const tableModifications = require('./tableModifications');
|
||||||
|
const views = require('./views');
|
||||||
|
const programmables = require('./programmables');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
columns,
|
columns,
|
||||||
@@ -10,4 +12,6 @@ module.exports = {
|
|||||||
primaryKeys,
|
primaryKeys,
|
||||||
foreignKeys,
|
foreignKeys,
|
||||||
tableModifications,
|
tableModifications,
|
||||||
|
views,
|
||||||
|
programmables,
|
||||||
};
|
};
|
||||||
|
|||||||
8
packages/engines/mysql/sql/programmables.js
Normal file
8
packages/engines/mysql/sql/programmables.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module.exports = `
|
||||||
|
select
|
||||||
|
ROUTINE_NAME as pureName,
|
||||||
|
ROUTINE_TYPE as objectType,
|
||||||
|
ROUTINE_DEFINITION as createSql
|
||||||
|
from information_schema.routines
|
||||||
|
where ROUTINE_SCHEMA = '#DATABASE#'
|
||||||
|
`;
|
||||||
@@ -3,5 +3,5 @@ select
|
|||||||
TABLE_NAME as pureName,
|
TABLE_NAME as pureName,
|
||||||
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as alterTime
|
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as alterTime
|
||||||
from information_schema.tables
|
from information_schema.tables
|
||||||
where TABLE_SCHEMA = '#DATABASE#' and TABLE_NAME =[OBJECT_NAME_CONDITION];
|
where TABLE_SCHEMA = '#DATABASE#' and TABLE_TYPE='BASE TABLE' and TABLE_NAME =[OBJECT_NAME_CONDITION];
|
||||||
`;
|
`;
|
||||||
|
|||||||
7
packages/engines/mysql/sql/views.js
Normal file
7
packages/engines/mysql/sql/views.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module.exports = `
|
||||||
|
select
|
||||||
|
TABLE_NAME as pureName,
|
||||||
|
VIEW_DEFINITION as createSql
|
||||||
|
from information_schema.views
|
||||||
|
where TABLE_SCHEMA = '#DATABASE#' and TABLE_NAME =[OBJECT_NAME_CONDITION];
|
||||||
|
`;
|
||||||
Reference in New Issue
Block a user