- added create tables to anonymous block
@ -79,6 +79,15 @@ export class QueryHelper {
this.pool = pgPool;
}
/**
* Async init function
*/
public async init() {
await this.pool.connect();
await this.createTables();
await this.updateTableDefinitions();
* creates all tables needed if a filepath was given with the constructor
@ -42,8 +42,12 @@ namespace dataaccess {
* Initializes everything that needs to be initialized asynchronous.
export async function init() {
await queryHelper.createTables();
await queryHelper.updateTableDefinitions();
try {
await queryHelper.init();
} catch (err) {
globals.logger.error(err.message);
globals.logger.debug(err.stack);
@ -49,6 +49,7 @@ DO $$ BEGIN
END$$;
-- create tables
DO $$ BEGIN
CREATE TABLE IF NOT EXISTS "user_sessions" (
"sid" varchar NOT NULL,
@ -126,3 +127,5 @@ CREATE TABLE IF NOT EXISTS requests (
type requesttype DEFAULT 'FRIENDREQUEST',
PRIMARY KEY (sender, receiver, type)
);
END $$;