--- create-facebook-messages

CREATE TABLE facebook_messages (
  id                     BIGINT      NOT NULL PRIMARY KEY,
  channel_id             BIGINT      NOT NULL  REFERENCES facebook_channels (id),
  user_id                BIGINT REFERENCES facebook_users (id),
  chat_message_id        BIGINT REFERENCES chat_messages (id),
  facebook_message_id    VARCHAR,
  facebook_attachment_id INTEGER NOT NULL DEFAULT 0,
  facebook_raw_message   VARCHAR,
  out                    BOOLEAN     NOT NULL  DEFAULT FALSE,
  sent                   BOOLEAN     NOT NULL  DEFAULT FALSE,
  created_at             TIMESTAMPTZ NOT NULL  DEFAULT now(),
  sent_at                TIMESTAMPTZ
);

CREATE SEQUENCE facebook_messages_id_seq;