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

                                  [type] NVARCHAR(255) not null,
                                  [text] NVARCHAR(2000) not null,
                                  file_id VARCHAR(255) references files(id),

                                  created_at DATETIMEOFFSET NOT NULL,
                                  updated_at DATETIMEOFFSET NOT NULL,
                                  sent_at DATETIMEOFFSET
);


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