2025-01-20 22:05:34 -08:00
|
|
|
// When this file changes, run the following command to generate a new migration:
|
|
|
|
|
// DATABASE_URL=/tmp/db.sql diesel migration generate --diff-schema create_conversations
|
|
|
|
|
|
2024-12-14 19:03:27 -08:00
|
|
|
diesel::table! {
|
|
|
|
|
conversations (id) {
|
|
|
|
|
id -> Text,
|
|
|
|
|
unread_count -> BigInt,
|
|
|
|
|
display_name -> Nullable<Text>,
|
|
|
|
|
last_message_preview -> Nullable<Text>,
|
|
|
|
|
date -> Timestamp,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diesel::table! {
|
|
|
|
|
participants (id) {
|
|
|
|
|
id -> Integer,
|
2025-01-20 22:05:34 -08:00
|
|
|
display_name -> Nullable<Text>,
|
|
|
|
|
is_me -> Bool,
|
2024-12-14 19:03:27 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diesel::table! {
|
|
|
|
|
conversation_participants (conversation_id, participant_id) {
|
|
|
|
|
conversation_id -> Text,
|
|
|
|
|
participant_id -> Integer,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-20 22:05:34 -08:00
|
|
|
diesel::table! {
|
|
|
|
|
messages (id) {
|
|
|
|
|
id -> Text, // guid
|
|
|
|
|
text -> Text,
|
|
|
|
|
sender_participant_id -> Nullable<Integer>,
|
|
|
|
|
date -> Timestamp,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diesel::table! {
|
|
|
|
|
conversation_messages (conversation_id, message_id) {
|
|
|
|
|
conversation_id -> Text, // guid
|
|
|
|
|
message_id -> Text, // guid
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-25 15:42:46 -07:00
|
|
|
diesel::table! {
|
|
|
|
|
settings (key) {
|
|
|
|
|
key -> Text,
|
|
|
|
|
value -> Binary,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-14 19:03:27 -08:00
|
|
|
diesel::joinable!(conversation_participants -> conversations (conversation_id));
|
|
|
|
|
diesel::joinable!(conversation_participants -> participants (participant_id));
|
|
|
|
|
diesel::allow_tables_to_appear_in_same_query!(conversations, participants, conversation_participants);
|
2025-01-20 22:05:34 -08:00
|
|
|
|
|
|
|
|
diesel::joinable!(conversation_messages -> conversations (conversation_id));
|
|
|
|
|
diesel::joinable!(conversation_messages -> messages (message_id));
|
|
|
|
|
diesel::allow_tables_to_appear_in_same_query!(conversations, messages, conversation_messages);
|