mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user