--- create-telegram-messages

CREATE TABLE telegram_messages (
  id                   BIGINT IDENTITY (1, 1) NOT NULL PRIMARY KEY,
  channel_id           BIGINT                 NOT NULL  REFERENCES telegram_channels (id),
  user_id              BIGINT REFERENCES telegram_users (id),
  chat_message_id      BIGINT REFERENCES chat_messages (id),
  telegram_message_id  BIGINT,
  telegram_raw_message VARCHAR(8000),
  out                  BIT,
  sent                 BIT                              DEFAULT 0,
  created_at           DATETIMEOFFSET         NOT NULL  DEFAULT SYSDATETIMEOFFSET(),
  sent_at              DATETIMEOFFSET
);
