From ed211f2d72d933040b583293dc1735eeeb179c5b Mon Sep 17 00:00:00 2001 From: Akulij Date: Thu, 10 Apr 2025 21:11:14 +0900 Subject: [PATCH] create table media --- migrations/2025-04-10-120721_media_table/down.sql | 2 ++ migrations/2025-04-10-120721_media_table/up.sql | 6 ++++++ src/db/models.rs | 9 +++++++++ src/db/schema.rs | 10 ++++++++++ 4 files changed, 27 insertions(+) create mode 100644 migrations/2025-04-10-120721_media_table/down.sql create mode 100644 migrations/2025-04-10-120721_media_table/up.sql diff --git a/migrations/2025-04-10-120721_media_table/down.sql b/migrations/2025-04-10-120721_media_table/down.sql new file mode 100644 index 0000000..d6b3f1f --- /dev/null +++ b/migrations/2025-04-10-120721_media_table/down.sql @@ -0,0 +1,2 @@ +DROP TABLE media; + diff --git a/migrations/2025-04-10-120721_media_table/up.sql b/migrations/2025-04-10-120721_media_table/up.sql new file mode 100644 index 0000000..39947d4 --- /dev/null +++ b/migrations/2025-04-10-120721_media_table/up.sql @@ -0,0 +1,6 @@ +CREATE TABLE media ( + id SERIAL PRIMARY KEY, + token VARCHAR NOT NULL, + media_type VARCHAR NOT NULL, + file_id VARCHAR NOT NULL +); diff --git a/src/db/models.rs b/src/db/models.rs index d947173..9a593f7 100644 --- a/src/db/models.rs +++ b/src/db/models.rs @@ -24,6 +24,15 @@ pub struct Literal { pub value: String, } +#[derive(Queryable, Debug, Identifiable)] +#[diesel(table_name = media)] +pub struct Media { + pub id: i32, + pub token: String, + pub media_type: String, + pub file_id: String, +} + #[derive(Queryable, Debug, Identifiable)] #[diesel(table_name = messages)] pub struct Message { diff --git a/src/db/schema.rs b/src/db/schema.rs index 2c8e625..c1c709e 100644 --- a/src/db/schema.rs +++ b/src/db/schema.rs @@ -16,6 +16,15 @@ diesel::table! { } } +diesel::table! { + media (id) { + id -> Int4, + token -> Varchar, + media_type -> Varchar, + file_id -> Varchar, + } +} + diesel::table! { messages (id) { id -> Int4, @@ -66,6 +75,7 @@ diesel::joinable!(reservations -> users (user_id)); diesel::allow_tables_to_appear_in_same_query!( events, literals, + media, messages, reservations, teloxide_dialogues,