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
|
// create connection to database
|
||||||
db.connect()
|
db.connect()
|
||||||
.then(() => console.log('Successfully connected to database'))
|
.then(() => {
|
||||||
.catch((err) => console.log('Error on connecting to database: ', err));
|
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() {
|
async function createTables() {
|
||||||
try {
|
try {
|
||||||
// Create accounts table
|
// Create accounts table
|
||||||
|
|||||||
Reference in New Issue
Block a user