createSchema_ method
Implementation
Future<void> createSchema_(String? correlationId) async {
if (this._schemaStatements == null || this._schemaStatements.length == 0) {
return null;
}
// Check if table exist to determine weither to auto create objects
// Todo: Add support for schema
var query = "SELECT to_regclass('" + this.tableName_! + "')";
var res = await client_!.query(query);
var exist = res.first.isNotEmpty && res.first[0] != null ? true : false;
// If table already exists then exit
if (exist) return;
logger_.debug(
correlationId,
'Table ' +
this.tableName_.toString() +
' does not exist. Creating database objects...');
// Run all DML commands
for (var dml in this._schemaStatements) {
try {
await client_!.query(dml);
} catch (ex) {
logger_.error(correlationId, ex as Exception,
'Failed to autocreate database object');
throw ex;
}
}
}