// 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 diesel::table! { conversations (id) { id -> Text, unread_count -> BigInt, display_name -> Nullable, last_message_preview -> Nullable, date -> Timestamp, } } diesel::table! { participants (handle) { handle -> Text, is_me -> Bool, contact_id -> Nullable, } } diesel::table! { conversation_participants (conversation_id, participant_handle) { conversation_id -> Text, participant_handle -> Text, } } diesel::table! { messages (id) { id -> Text, // guid text -> Text, sender_participant_handle -> Nullable, date -> Timestamp, file_transfer_guids -> Nullable, // JSON array of file transfer GUIDs attachment_metadata -> Nullable, // JSON string of attachment metadata } } diesel::table! { conversation_messages (conversation_id, message_id) { conversation_id -> Text, // guid message_id -> Text, // guid } } diesel::table! { settings (key) { key -> Text, value -> Binary, } } diesel::joinable!(conversation_participants -> conversations (conversation_id)); diesel::joinable!(conversation_participants -> participants (participant_handle)); diesel::joinable!(messages -> participants (sender_participant_handle)); diesel::joinable!(conversation_messages -> conversations (conversation_id)); diesel::joinable!(conversation_messages -> messages (message_id)); diesel::allow_tables_to_appear_in_same_query!( conversations, participants, conversation_participants, messages, conversation_messages, settings, );