generate update script

This commit is contained in:
Jan Prochazka
2020-03-23 20:41:40 +01:00
parent 1560b7c2e0
commit 464662cb18
17 changed files with 281 additions and 71 deletions

View File

@@ -0,0 +1,18 @@
import { EngineDriver, SqlDumper } from '@dbgate/types';
import { Command } from './types';
import { dumpSqlCommand } from './dumpSqlCommand';
export function treeToSql<T>(driver: EngineDriver, object: T, func: (dmp: SqlDumper, obj: T) => void) {
const dmp = driver.createDumper();
func(dmp, object);
return dmp.s;
}
export function scriptToSql(driver: EngineDriver, script: Command[]): string {
const dmp = driver.createDumper();
for (const cmd of script) {
dumpSqlCommand(dmp, cmd);
dmp.endCommand();
}
return dmp.s;
}