mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
using GO separator for MS SQL db sync
This commit is contained in:
parent
9dcc235f5a
commit
8fd2c78b6a
@ -468,7 +468,7 @@ export function getAlterTableScript(
|
||||
}
|
||||
|
||||
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();
|
||||
plan.run(dmp);
|
||||
if (!driver.dialect.disableExplicitTransaction) dmp.commitTransaction();
|
||||
@ -487,7 +487,7 @@ export function getAlterDatabaseScript(
|
||||
driver: EngineDriver
|
||||
) {
|
||||
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();
|
||||
plan.run(dmp);
|
||||
if (!driver.dialect.disableExplicitTransaction) dmp.commitTransaction();
|
||||
|
@ -32,8 +32,8 @@ export const driverBase = {
|
||||
const analyser = new this.analyserClass(pool, this, version);
|
||||
return analyser.incrementalAnalysis(structure);
|
||||
},
|
||||
createDumper() {
|
||||
return new this.dumperClass(this);
|
||||
createDumper(options = null) {
|
||||
return new this.dumperClass(this, options);
|
||||
},
|
||||
async script(pool, sql) {
|
||||
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>;
|
||||
dialect: SqlDialect;
|
||||
dialectByVersion(version): SqlDialect;
|
||||
createDumper(): SqlDumper;
|
||||
createDumper(options = null): SqlDumper;
|
||||
getAuthTypes(): EngineAuthType[];
|
||||
readCollection(pool: any, options: ReadCollectionOptions): Promise<any>;
|
||||
updateCollection(pool: any, changeSet: any): Promise<any>;
|
||||
|
@ -186,6 +186,7 @@
|
||||
|
||||
$: console.log('sourceDb', sourceDb);
|
||||
$: console.log('targetDb', targetDb);
|
||||
$: console.log('connection', connection);
|
||||
$: console.log('driver', driver);
|
||||
|
||||
$: targetDbPaired = matchPairedObjects(sourceDb, targetDb, dbDiffOptions);
|
||||
|
@ -1,6 +1,21 @@
|
||||
const { SqlDumper, testEqualColumns } = global.DBGATE_TOOLS;
|
||||
|
||||
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() {
|
||||
this.put(' ^identity');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user