import Conversion from './Conversion' ; import DBAccess from './DBAccess' ; import DBAccessQueryResult from './DBAccessQueryResult' ; import IDBAccessQueryParams from './IDBAccessQueryParams' ; import DBVendors from './DBVendors' ; /**
 * Creates a new PostgreSQL schema if it does not exist yet.
 */ export default async ( conversion ) : Promise < Conversion > => { const params = { conversion : conversion , caller : 'SchemaProcessor::createSchema' , sql : `SELECT schema_name FROM information_schema.schemata WHERE schema_name = '${ conversion . _schema }';` , vendor : DBVendors . PG , processExitOnError : true , shouldReturnClient : true } ; const result = await DBAccess . query ( params ) ; if ( result . data . rows . length === 0 ) { params . sql = `CREATE SCHEMA "${ conversion . _schema }";` ; params . shouldReturnClient = false ; params . client = result . client ; await DBAccess . query ( params ) ; } return conversion ; } ;