create table only if database connection was successful
This commit is contained in:
@@ -11,9 +11,17 @@ const db = new Client({
|
||||
|
||||
// create connection to database
|
||||
db.connect()
|
||||
.then(() => console.log('Successfully connected to database'))
|
||||
.catch((err) => console.log('Error on connecting to database: ', err));
|
||||
|
||||
.then(() => {
|
||||
console.log('Successfully connected to database');
|
||||
// if connection is succesful create tables
|
||||
createTables()
|
||||
.catch((err) => {
|
||||
console.error('Error creating tables:', err);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Error connecting to database: ', err);
|
||||
})
|
||||
async function createTables() {
|
||||
try {
|
||||
// Create accounts table
|
||||
|
||||
Reference in New Issue
Block a user