in lib/lambda/createQldbTables/CreateTables.ts [29:60]
export async function createQldbTables(
qldbDriver: qldb.QldbDriver,
tableNameList: string,
): Promise<void> {
const existingTableNames = await qldbDriver.getTableNames();
const existingTableNamesLc = existingTableNames.map( e => e.toLowerCase() );
console.log(`Existing table names with lowercase are ${existingTableNamesLc}`);
const tableList = tableNameList.split(',').map(e => e.trim());
const tablesToCreate = tableList.filter( e => {return !existingTableNamesLc.includes(e.toLowerCase())} );
console.log(`Tables to be created are ${tablesToCreate}`)
if(tablesToCreate.length > 0)
{
try {
await qldbDriver.executeLambda(async (txn: qldb.TransactionExecutor) => {
Promise.all(tablesToCreate.map( (table: string) => {
createTable(txn, table);
}));
});
} catch (e) {
console.log(`Unable to create tables: ${e}`);
}
} else {
console.log('All required tables are existing in QLDB ledger, no more table to be created')
}
};