From e782e6640f3cb402d924598726bbc8295fe53cfb Mon Sep 17 00:00:00 2001 From: ATechnoHazard Date: Wed, 24 Jun 2020 22:41:01 +0530 Subject: [PATCH] diesel: Create migrations for users and pastes Signed-off-by: ATechnoHazard --- .../2020-06-24-164134_create_users/down.sql | 1 + .../2020-06-24-164134_create_users/up.sql | 7 ++++ .../2020-06-24-170630_create_paste/down.sql | 1 + .../2020-06-24-170630_create_paste/up.sql | 7 ++++ src/schema.rs | 34 +++++++++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 migrations/2020-06-24-164134_create_users/down.sql create mode 100644 migrations/2020-06-24-164134_create_users/up.sql create mode 100644 migrations/2020-06-24-170630_create_paste/down.sql create mode 100644 migrations/2020-06-24-170630_create_paste/up.sql create mode 100644 src/schema.rs diff --git a/migrations/2020-06-24-164134_create_users/down.sql b/migrations/2020-06-24-164134_create_users/down.sql new file mode 100644 index 0000000..ea15b38 --- /dev/null +++ b/migrations/2020-06-24-164134_create_users/down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS users \ No newline at end of file diff --git a/migrations/2020-06-24-164134_create_users/up.sql b/migrations/2020-06-24-164134_create_users/up.sql new file mode 100644 index 0000000..55355d2 --- /dev/null +++ b/migrations/2020-06-24-164134_create_users/up.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS users +( + id VARCHAR PRIMARY KEY, + username VARCHAR, + password VARCHAR, + activated BOOLEAN +) \ No newline at end of file diff --git a/migrations/2020-06-24-170630_create_paste/down.sql b/migrations/2020-06-24-170630_create_paste/down.sql new file mode 100644 index 0000000..f5fa99c --- /dev/null +++ b/migrations/2020-06-24-170630_create_paste/down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS pastes \ No newline at end of file diff --git a/migrations/2020-06-24-170630_create_paste/up.sql b/migrations/2020-06-24-170630_create_paste/up.sql new file mode 100644 index 0000000..88a0ae3 --- /dev/null +++ b/migrations/2020-06-24-170630_create_paste/up.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS pastes +( + id VARCHAR PRIMARY KEY, + belongs_to VARCHAR references users(id), + is_url BOOLEAN NOT NULL DEFAULT 'f', + content TEXT NOT NULL +) \ No newline at end of file diff --git a/src/schema.rs b/src/schema.rs new file mode 100644 index 0000000..1564ab4 --- /dev/null +++ b/src/schema.rs @@ -0,0 +1,34 @@ +table! { + games (id) { + id -> Int4, + name -> Text, + developer -> Text, + is_goty -> Bool, + } +} + +table! { + pastes (id) { + id -> Varchar, + belongs_to -> Nullable, + is_url -> Bool, + content -> Text, + } +} + +table! { + users (id) { + id -> Varchar, + username -> Nullable, + password -> Nullable, + activated -> Nullable, + } +} + +joinable!(pastes -> users (belongs_to)); + +allow_tables_to_appear_in_same_query!( + games, + pastes, + users, +);