mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 21:46:00 +00:00
mssql - incremental analysis
This commit is contained in:
@@ -1,50 +1,34 @@
|
||||
const fp = require("lodash/fp");
|
||||
const _ = require("lodash");
|
||||
const sql = require('./sql')
|
||||
const fp = require('lodash/fp');
|
||||
const _ = require('lodash');
|
||||
const sql = require('./sql');
|
||||
|
||||
const DatabaseAnalayser = require("../default/DatabaseAnalyser");
|
||||
const DatabaseAnalayser = require('../default/DatabaseAnalyser');
|
||||
|
||||
class MySqlAnalyser extends DatabaseAnalayser {
|
||||
constructor(pool, driver) {
|
||||
super(pool, driver);
|
||||
}
|
||||
|
||||
async createQuery(
|
||||
resFileName,
|
||||
tables = false,
|
||||
views = false,
|
||||
procedures = false,
|
||||
functions = false,
|
||||
triggers = false
|
||||
) {
|
||||
createQuery(resFileName, tables = false, views = false, procedures = false, functions = false, triggers = false) {
|
||||
let res = sql[resFileName];
|
||||
res = res.replace("=[OBJECT_ID_CONDITION]", " is not null");
|
||||
res = res.replace('=[OBJECT_ID_CONDITION]', ' is not null');
|
||||
return res;
|
||||
}
|
||||
async runAnalysis() {
|
||||
const tables = await this.driver.query(
|
||||
this.pool,
|
||||
await this.createQuery("tableModifications")
|
||||
);
|
||||
const columns = await this.driver.query(
|
||||
this.pool,
|
||||
await this.createQuery("columns")
|
||||
);
|
||||
// const pkColumns = await this.driver.query(this.pool, await this.createQuery('primary_keys.sql'));
|
||||
// const fkColumns = await this.driver.query(this.pool, await this.createQuery('foreign_keys.sql'));
|
||||
const tables = await this.driver.query(this.pool, this.createQuery('tableModifications'));
|
||||
const columns = await this.driver.query(this.pool, this.createQuery('columns'));
|
||||
// const pkColumns = await this.driver.query(this.pool, this.createQuery('primary_keys.sql'));
|
||||
// const fkColumns = await this.driver.query(this.pool, this.createQuery('foreign_keys.sql'));
|
||||
|
||||
this.result.tables = tables.rows.map(table => ({
|
||||
this.result.tables = tables.rows.map((table) => ({
|
||||
...table,
|
||||
columns: columns.rows
|
||||
.filter(
|
||||
col =>
|
||||
col.pureName == table.pureName && col.schemaName == table.schemaName
|
||||
)
|
||||
.filter((col) => col.pureName == table.pureName && col.schemaName == table.schemaName)
|
||||
.map(({ isNullable, ...col }) => ({
|
||||
...col,
|
||||
notNull: !isNullable
|
||||
notNull: !isNullable,
|
||||
})),
|
||||
foreignKeys: []
|
||||
foreignKeys: [],
|
||||
// primaryKey: extractPrimaryKeys(table, pkColumns.rows),
|
||||
// foreignKeys: extractForeignKeys(table, fkColumns.rows),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user