From 3fc548058bac5ef33f3955f4188bf6bea9ac9311 Mon Sep 17 00:00:00 2001 From: WriterV2 Date: Wed, 6 Nov 2024 17:38:25 +0100 Subject: Feat: Update db to set tag for product instead of specific product --- .dockerignore | 1 + documentation/er-model.pdf | Bin 0 -> 142284 bytes migrations/20241106161637_tagredesign.sql | 13 +++++++++++++ src/db/gametag.rs | 5 ----- src/db/mod.rs | 4 +--- src/db/producttag.rs | 5 +++++ src/db/storytag.rs | 5 ----- src/db/tooltag.rs | 5 ----- 8 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 documentation/er-model.pdf create mode 100644 migrations/20241106161637_tagredesign.sql delete mode 100644 src/db/gametag.rs create mode 100644 src/db/producttag.rs delete mode 100644 src/db/storytag.rs delete mode 100644 src/db/tooltag.rs diff --git a/.dockerignore b/.dockerignore index c3e7034..fc04251 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,4 @@ target/ .git/ .env *.db +documentation/ diff --git a/documentation/er-model.pdf b/documentation/er-model.pdf new file mode 100644 index 0000000..2a6d49c Binary files /dev/null and b/documentation/er-model.pdf differ diff --git a/migrations/20241106161637_tagredesign.sql b/migrations/20241106161637_tagredesign.sql new file mode 100644 index 0000000..c33cec3 --- /dev/null +++ b/migrations/20241106161637_tagredesign.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS storytag; +DROP TABLE IF EXISTS gametag; +DROP TABLE IF EXISTS tooltag; + +CREATE TABLE IF NOT EXISTS producttag +( + pid INTEGER NOT NULL, + tid INTEGER NOT NULL, + FOREIGN KEY (pid) REFERENCES product(id), + FOREIGN KEY (tid) REFERENCES tag(id), + PRIMARY KEY (pid, tid) +); + diff --git a/src/db/gametag.rs b/src/db/gametag.rs deleted file mode 100644 index 335d2a4..0000000 --- a/src/db/gametag.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Debug, serde::Serialize, sqlx::FromRow)] -pub struct Gametag { - pub gid: i64, - pub tgid: i64, -} diff --git a/src/db/mod.rs b/src/db/mod.rs index 0b310c6..7050527 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -4,13 +4,11 @@ use crate::error::AppError; use async_trait::async_trait; pub mod game; -pub mod gametag; pub mod product; +pub mod producttag; pub mod story; -pub mod storytag; pub mod tag; pub mod tool; -pub mod tooltag; #[async_trait] pub trait ProductDatabaseHandler { diff --git a/src/db/producttag.rs b/src/db/producttag.rs new file mode 100644 index 0000000..b3091c3 --- /dev/null +++ b/src/db/producttag.rs @@ -0,0 +1,5 @@ +#[derive(Debug, serde::Serialize, sqlx::FromRow)] +pub struct Storytag { + pub pid: i64, + pub tid: i64, +} diff --git a/src/db/storytag.rs b/src/db/storytag.rs deleted file mode 100644 index 0953fc2..0000000 --- a/src/db/storytag.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Debug, serde::Serialize, sqlx::FromRow)] -pub struct Storytag { - pub sid: i64, - pub tgid: i64, -} diff --git a/src/db/tooltag.rs b/src/db/tooltag.rs deleted file mode 100644 index 393e687..0000000 --- a/src/db/tooltag.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Debug, serde::Serialize, sqlx::FromRow)] -pub struct Tooltag { - pub tid: i64, - pub tgid: i64, -} -- cgit v1.2.3