From b8e52791bb50007549693c24b78f89d2af588ebc Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Sat, 4 Nov 2023 02:56:05 -0700 Subject: [PATCH] formatting and new tables --- .../2023-09-24-104018_create_shifts/down.sql | 2 +- .../2023-09-30-201752_create_drinks/up.sql | 2 +- .../2023-11-04-093412_create_dancers/up.sql | 12 +++++------ .../2023-11-04-093417_create_shows/down.sql | 2 ++ .../2023-11-04-093417_create_shows/up.sql | 9 +++++++++ src/lib/schema.rs | 20 +++++++++++++++++++ 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 migrations/2023-11-04-093417_create_shows/down.sql create mode 100644 migrations/2023-11-04-093417_create_shows/up.sql diff --git a/migrations/2023-09-24-104018_create_shifts/down.sql b/migrations/2023-09-24-104018_create_shifts/down.sql index d080e55..b369385 100644 --- a/migrations/2023-09-24-104018_create_shifts/down.sql +++ b/migrations/2023-09-24-104018_create_shifts/down.sql @@ -1,2 +1,2 @@ -- This file should undo anything in `up.sql` -DROP TABLE shifts +DROP TABLE shifts; diff --git a/migrations/2023-09-30-201752_create_drinks/up.sql b/migrations/2023-09-30-201752_create_drinks/up.sql index 169dbb4..2ddc9de 100644 --- a/migrations/2023-09-30-201752_create_drinks/up.sql +++ b/migrations/2023-09-30-201752_create_drinks/up.sql @@ -7,4 +7,4 @@ CREATE TABLE shift INT UNSIGNED NOT NULL, time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, FOREIGN KEY (shift) REFERENCES shifts (id) ON DELETE CASCADE - ) + ); diff --git a/migrations/2023-11-04-093412_create_dancers/up.sql b/migrations/2023-11-04-093412_create_dancers/up.sql index 6875a9a..4e98468 100644 --- a/migrations/2023-11-04-093412_create_dancers/up.sql +++ b/migrations/2023-11-04-093412_create_dancers/up.sql @@ -1,7 +1,7 @@ -- Your SQL goes here -CREATE TABLE dancers -( - id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, - stage_name TEXT - name TEXT, -) +CREATE TABLE + dancers ( + id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, + stage_name TEXT NOT NULL, + name TEXT NOT NULL + ) diff --git a/migrations/2023-11-04-093417_create_shows/down.sql b/migrations/2023-11-04-093417_create_shows/down.sql new file mode 100644 index 0000000..546ae13 --- /dev/null +++ b/migrations/2023-11-04-093417_create_shows/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +DROP TABLE shows; diff --git a/migrations/2023-11-04-093417_create_shows/up.sql b/migrations/2023-11-04-093417_create_shows/up.sql new file mode 100644 index 0000000..63dee6c --- /dev/null +++ b/migrations/2023-11-04-093417_create_shows/up.sql @@ -0,0 +1,9 @@ +-- Your SQL goes here +CREATE TABLE + shows ( + id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, + dancer INT UNSIGNED NOT NULL, + start DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + end DATETIME DEFAULT NULL, + FOREIGN KEY (dancer) REFERENCES dancers (id) ON DELETE RESTRICT + ) diff --git a/src/lib/schema.rs b/src/lib/schema.rs index 2f49b49..fd547f1 100644 --- a/src/lib/schema.rs +++ b/src/lib/schema.rs @@ -1,5 +1,13 @@ // @generated automatically by Diesel CLI. +diesel::table! { + dancers (id) { + id -> Unsigned, + stage_name -> Text, + name -> Text, + } +} + diesel::table! { drinks (id) { id -> Unsigned, @@ -18,9 +26,21 @@ diesel::table! { } } +diesel::table! { + shows (id) { + id -> Unsigned, + dancer -> Unsigned, + start -> Datetime, + end -> Nullable, + } +} + diesel::joinable!(drinks -> shifts (shift)); +diesel::joinable!(shows -> dancers (dancer)); diesel::allow_tables_to_appear_in_same_query!( + dancers, drinks, shifts, + shows, );