create table public.concardispayengine_configuration
(
  customer text not null
    constraint concardis_payengine_configuration_pk
      primary key
    constraint concardis_payengine_configuration_paymenthub_configuration_cust
      references public.paymenthub_configuration
      on update restrict on delete restrict,
  logfile text not null,
  instance text not null,
  api_key text not null,
  backend_url text not null,
  backend_url_endpoints json not null
);

alter table public.concardispayengine_configuration owner to paymenthub;

create table public.concardispayengine_payment
(
  id bigserial not null
    constraint concardis_payengine_payment_pk
      primary key,
  customer text
    constraint concardis_payengine_payment_concardis_payengine_configuration_c
      references public.concardispayengine_configuration
      on update restrict on delete restrict,
  initiator json not null,
  reference text not null,
  internal_reference text,
  amount integer not null,
  payment_method text,
  paid boolean default false not null,
  failed boolean default false not null,
  cancelled boolean default false not null,
  pending boolean default false not null,
  transfer_data boolean default false not null,
  transferred boolean default false not null,
  create_timestamp timestamp default (now())::timestamp without time zone not null,
  request jsonb,
  response jsonb,
  notification_timestamp timestamp without time zone[],
  notification jsonb,
  url_callback jsonb
);

alter table public.concardispayengine_payment owner to paymenthub;

