CREATE TABLE IF NOT EXISTS orders (
  id char(36) primary key not null,
  kind varchar(4) not null,
  event_id char(64) not null,
  hash char(64),
  preimage char(64),
  creator_pubkey char(64),
  cancel_initiator_pubkey char(64),
  dispute_initiator_pubkey char(64),
  buyer_pubkey char(64),
  master_buyer_pubkey char(64),
  seller_pubkey char(64),
  master_seller_pubkey char(64),
  status varchar(10) not null,
  price_from_api integer not null default 0,
  premium integer not null,
  payment_method varchar(500) not null,
  amount integer not null,
  min_amount integer default 0,
  max_amount integer default 0,
  buyer_dispute integer not null default 0,
  seller_dispute integer not null default 0,
  buyer_cooperativecancel integer not null default 0,
  seller_cooperativecancel integer not null default 0,
  fee integer not null default 0,
  routing_fee integer not null default 0,
  fiat_code varchar(5) not null,
  fiat_amount integer not null,
  buyer_invoice text,
  range_parent_id char(36),
  invoice_held_at integer default 0,
  taken_at integer default 0,
  created_at integer not null,
  buyer_sent_rate integer default 0,
  seller_sent_rate integer default 0,
  payment_attempts integer default 0,
  failed_payment integer default 0,
  expires_at integer not null
);