mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 14:33:59 +00:00
using GO separator for MS SQL db sync
This commit is contained in:
@@ -468,7 +468,7 @@ export function getAlterTableScript(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const plan = createAlterTablePlan(oldTable, newTable, opts, wholeOldDb, wholeNewDb, driver);
|
const plan = createAlterTablePlan(oldTable, newTable, opts, wholeOldDb, wholeNewDb, driver);
|
||||||
const dmp = driver.createDumper();
|
const dmp = driver.createDumper({ useHardSeparator: true });
|
||||||
if (!driver.dialect.disableExplicitTransaction) dmp.beginTransaction();
|
if (!driver.dialect.disableExplicitTransaction) dmp.beginTransaction();
|
||||||
plan.run(dmp);
|
plan.run(dmp);
|
||||||
if (!driver.dialect.disableExplicitTransaction) dmp.commitTransaction();
|
if (!driver.dialect.disableExplicitTransaction) dmp.commitTransaction();
|
||||||
@@ -487,7 +487,7 @@ export function getAlterDatabaseScript(
|
|||||||
driver: EngineDriver
|
driver: EngineDriver
|
||||||
) {
|
) {
|
||||||
const plan = createAlterDatabasePlan(oldDb, newDb, opts, wholeOldDb, wholeNewDb, driver);
|
const plan = createAlterDatabasePlan(oldDb, newDb, opts, wholeOldDb, wholeNewDb, driver);
|
||||||
const dmp = driver.createDumper();
|
const dmp = driver.createDumper({ useHardSeparator: true });
|
||||||
if (!driver.dialect.disableExplicitTransaction) dmp.beginTransaction();
|
if (!driver.dialect.disableExplicitTransaction) dmp.beginTransaction();
|
||||||
plan.run(dmp);
|
plan.run(dmp);
|
||||||
if (!driver.dialect.disableExplicitTransaction) dmp.commitTransaction();
|
if (!driver.dialect.disableExplicitTransaction) dmp.commitTransaction();
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ export const driverBase = {
|
|||||||
const analyser = new this.analyserClass(pool, this, version);
|
const analyser = new this.analyserClass(pool, this, version);
|
||||||
return analyser.incrementalAnalysis(structure);
|
return analyser.incrementalAnalysis(structure);
|
||||||
},
|
},
|
||||||
createDumper() {
|
createDumper(options = null) {
|
||||||
return new this.dumperClass(this);
|
return new this.dumperClass(this, options);
|
||||||
},
|
},
|
||||||
async script(pool, sql) {
|
async script(pool, sql) {
|
||||||
for (const sqlItem of splitQuery(sql, this.getQuerySplitterOptions('script'))) {
|
for (const sqlItem of splitQuery(sql, this.getQuerySplitterOptions('script'))) {
|
||||||
|
|||||||
2
packages/types/engines.d.ts
vendored
2
packages/types/engines.d.ts
vendored
@@ -72,7 +72,7 @@ export interface EngineDriver {
|
|||||||
analyseIncremental(pool: any, structure: DatabaseInfo, serverVersion): Promise<DatabaseInfo>;
|
analyseIncremental(pool: any, structure: DatabaseInfo, serverVersion): Promise<DatabaseInfo>;
|
||||||
dialect: SqlDialect;
|
dialect: SqlDialect;
|
||||||
dialectByVersion(version): SqlDialect;
|
dialectByVersion(version): SqlDialect;
|
||||||
createDumper(): SqlDumper;
|
createDumper(options = null): SqlDumper;
|
||||||
getAuthTypes(): EngineAuthType[];
|
getAuthTypes(): EngineAuthType[];
|
||||||
readCollection(pool: any, options: ReadCollectionOptions): Promise<any>;
|
readCollection(pool: any, options: ReadCollectionOptions): Promise<any>;
|
||||||
updateCollection(pool: any, changeSet: any): Promise<any>;
|
updateCollection(pool: any, changeSet: any): Promise<any>;
|
||||||
|
|||||||
@@ -186,6 +186,7 @@
|
|||||||
|
|
||||||
$: console.log('sourceDb', sourceDb);
|
$: console.log('sourceDb', sourceDb);
|
||||||
$: console.log('targetDb', targetDb);
|
$: console.log('targetDb', targetDb);
|
||||||
|
$: console.log('connection', connection);
|
||||||
$: console.log('driver', driver);
|
$: console.log('driver', driver);
|
||||||
|
|
||||||
$: targetDbPaired = matchPairedObjects(sourceDb, targetDb, dbDiffOptions);
|
$: targetDbPaired = matchPairedObjects(sourceDb, targetDb, dbDiffOptions);
|
||||||
|
|||||||
@@ -1,6 +1,21 @@
|
|||||||
const { SqlDumper, testEqualColumns } = global.DBGATE_TOOLS;
|
const { SqlDumper, testEqualColumns } = global.DBGATE_TOOLS;
|
||||||
|
|
||||||
class MsSqlDumper extends SqlDumper {
|
class MsSqlDumper extends SqlDumper {
|
||||||
|
constructor(driver, options) {
|
||||||
|
super(driver);
|
||||||
|
if (options && options.useHardSeparator) {
|
||||||
|
this.useHardSeparator = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endCommand() {
|
||||||
|
if (this.useHardSeparator) {
|
||||||
|
this.putRaw('\nGO\n');
|
||||||
|
} else {
|
||||||
|
super.endCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
autoIncrement() {
|
autoIncrement() {
|
||||||
this.put(' ^identity');
|
this.put(' ^identity');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user