2024-04-21 19:01:29 +00:00
|
|
|
create table dialogs(
|
2024-04-22 18:27:33 +00:00
|
|
|
id integer primary key autoincrement not null,
|
2024-04-21 19:01:29 +00:00
|
|
|
participant_1 integer not null,
|
|
|
|
participant_2 integer not null,
|
|
|
|
created_at timestamp not null,
|
|
|
|
message_count integer not null default 0,
|
2024-04-22 18:27:33 +00:00
|
|
|
unique (participant_1, participant_2)
|
2024-04-21 19:01:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
create table dialog_messages(
|
|
|
|
dialog_id integer not null,
|
|
|
|
id integer not null, -- unique per dialog, sequential in one dialog
|
2024-04-22 18:27:33 +00:00
|
|
|
author_id integer not null,
|
2024-04-21 19:01:29 +00:00
|
|
|
content string not null,
|
2024-04-22 18:27:33 +00:00
|
|
|
created_at timestamp not null,
|
2024-04-21 19:01:29 +00:00
|
|
|
primary key (dialog_id, id)
|
|
|
|
);
|