import { PostgresClient } from '@jvalue/node-dry-pg' ; import { POSTGRES_SCHEMA } from '../env' ; import { StorageStructureRepository } from './storageStructureRepository' ; const CREATE_BUCKET_STATEMENT = ( schema , table ) : string => `CREATE TABLE IF NOT EXISTS "${ schema }"."${ table }" (
  "id" bigint NOT NULL GENERATED ALWAYS AS IDENTITY,
  "data" jsonb NOT NULL,
  "timestamp" timestamp,
  "pipelineId" bigint,
  CONSTRAINT "Data_pk_${ schema }_${ table }" PRIMARY KEY (id)
  )` ; const DELETE_BUCKET_STATEMENT = ( schema , table ) : string => `DROP TABLE "${ schema }"."${ table }" CASCADE` ; export class PostgresStorageStructureRepository implements StorageStructureRepository { constructor ( private readonly postgresClient ) { } param tableIdentifier async create ( tableIdentifier ) { await this . postgresClient . executeQuery ( CREATE_BUCKET_STATEMENT ( POSTGRES_SCHEMA , tableIdentifier ) ) ; } param tableIdentifier async delete ( tableIdentifier ) { await this . postgresClient . executeQuery ( DELETE_BUCKET_STATEMENT ( POSTGRES_SCHEMA , tableIdentifier ) ) ; } }