Ensure that the 'CREATE SCHEMA' statement should be present in the generated script if the schema is not present in the target database. Fixes #5816

This commit is contained in:
Akshay Joshi
2020-09-11 19:06:56 +05:30
parent ed1bd74301
commit a7d40e238e
7 changed files with 69 additions and 56 deletions

View File

@@ -260,6 +260,15 @@ export default class SchemaDiffUI {
let data = self.grid.getData().getItem(sel_rows[row]);
if(!_.isUndefined(data.diff_ddl)) {
if (!(data.dependLevel in script_array)) script_array[data.dependLevel] = [];
// Check whether the selected object belongs to source only schema
// if yes then we will have to add create schema statement before
// creating any other object.
if (!_.isUndefined(data.source_schema_name) && !_.isNull(data.source_schema_name)) {
let schema_query = '\nCREATE SCHEMA IF NOT EXISTS ' + data.source_schema_name + ';\n';
if (script_array[data.dependLevel].indexOf(schema_query) == -1) {
script_array[data.dependLevel].push(schema_query);
}
}
script_array[data.dependLevel].push(data.diff_ddl);
}
}