CREATE TABLE IF NOT EXISTS concardis_configuration (
  customer text NOT NULL
    CONSTRAINT concardis_configuration_pkey PRIMARY KEY
    CONSTRAINT concardis_configuration_paymenthub_configuration_customer_fk REFERENCES paymenthub_configuration ON UPDATE RESTRICT ON DELETE RESTRICT,
  logfile text NOT NULL,
  secret_key text NOT NULL,
  checkout_key text NOT NULL,
  backend_url text NOT NULL,
  backend_url_endpoints json NOT NULL,
  checkout_url text NOT NULL,
  notify_url text NOT NULL,
  terms_url text NOT NULL
);

ALTER TABLE concardis_configuration
  OWNER TO paymenthub;

CREATE TABLE IF NOT EXISTS concardis_payment (
  id bigserial NOT NULL
    CONSTRAINT concardis_payment_pkey PRIMARY KEY,
  customer text NOT NULL
    CONSTRAINT concardis_payment_concardis_configuration_customer_fk REFERENCES concardis_configuration ON UPDATE RESTRICT ON DELETE RESTRICT,
  initiator json NOT NULL,
  reference text NOT NULL,
  internal_reference text,
  type text NOT NULL,
  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,
  charge_id text,
  notification_timestamp timestamp WITHOUT TIME ZONE[],
  notification jsonb
);

ALTER TABLE concardis_payment
  OWNER TO paymenthub;
