create table telegram_posts (
                                  id bigint primary key,
                                  public_id bigint not null references telegram_publics(id),
                                  user_id bigint not null references users(id),
                                  state varchar(255) not null,

                                  "type" varchar(255) not null,
                                  "text" varchar(2000) not null,
                                  file_id varchar(255) references files(id),

                                  created_at timestamptz not null,
                                  updated_at timestamptz not null,
                                  sent_at timestamptz
);

create sequence telegram_posts_id_seq;

create index telegram_posts_public_ix on telegram_posts(public_id, created_at desc);
