From fff11b4d52f0d1e1adbfe0bf14e5e8f7a25c8ad0 Mon Sep 17 00:00:00 2001
From: Janne Koschinski <janne@kuschku.de>
Date: Tue, 5 Jan 2021 21:08:12 +0100
Subject: [PATCH] Update schema for translated images

---
 migrations/2020-05-14-213742_create_database/up.sql | 1 +
 src/dto.rs                                          | 2 ++
 src/models.rs                                       | 1 +
 src/schema.rs                                       | 1 +
 4 files changed, 5 insertions(+)

diff --git a/migrations/2020-05-14-213742_create_database/up.sql b/migrations/2020-05-14-213742_create_database/up.sql
index 78e0081..b1555d4 100644
--- a/migrations/2020-05-14-213742_create_database/up.sql
+++ b/migrations/2020-05-14-213742_create_database/up.sql
@@ -131,6 +131,7 @@ create table if not exists title_images
 		constraint title_images_pkey
 			primary key,
 	kind text not null,
+	language text not null,
 	mime text not null,
 	src text not null,
 	created_at timestamp with time zone not null,
diff --git a/src/dto.rs b/src/dto.rs
index 96d5a4f..156a3e6 100644
--- a/src/dto.rs
+++ b/src/dto.rs
@@ -197,6 +197,7 @@ impl InstalmentDto {
 #[serde(rename_all = "camelCase")]
 pub struct ImageDto {
     pub kind: String,
+    pub language: Option<String>,
     pub mime: String,
     pub src: String,
 }
@@ -205,6 +206,7 @@ impl ImageDto {
     pub fn of(src: TitleImage, config: &Config) -> Result<Self, url::ParseError> {
         Ok(ImageDto {
             kind: src.kind,
+            language: src.language,
             mime: src.mime,
             src: absolute_url(config, UrlKind::Static, src.src)?,
         })
diff --git a/src/models.rs b/src/models.rs
index 46763aa..98a9cef 100644
--- a/src/models.rs
+++ b/src/models.rs
@@ -86,6 +86,7 @@ pub struct TitleGenre {
 pub struct TitleImage {
     pub id: uuid::Uuid,
     pub kind: String,
+    pub language: Option<String>,
     pub mime: String,
     pub src: String,
     pub created_at: chrono::DateTime<chrono::Utc>,
diff --git a/src/schema.rs b/src/schema.rs
index 539557a..034308c 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -72,6 +72,7 @@ table! {
     title_images (id) {
         id -> Uuid,
         kind -> Text,
+        language -> Nullable<Text>,
         mime -> Text,
         src -> Text,
         created_at -> Timestamptz,
-- 
GitLab