--- create-facebook-users

CREATE TABLE facebook_users (
  id              BIGINT PRIMARY KEY,
  channel_id      BIGINT NOT NULL REFERENCES facebook_channels (id),
  user_id         BIGINT NOT NULL,
  client_id       BIGINT REFERENCES clients (id),
  first_name      VARCHAR,
  last_name       VARCHAR,
  gender          VARCHAR,
  profile_picture VARCHAR
);

CREATE UNIQUE INDEX facebook_users_client_id_uniq
  ON facebook_users (client_id);

CREATE UNIQUE INDEX facebook_users_channel_user_uniq
  ON facebook_users (channel_id, user_id);

CREATE SEQUENCE facebook_users_id_seq;