From 7e04e6010a8ffd385d71704d059c451bbbe3d9e7 Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 10 Mar 2020 17:59:27 -0700 Subject: [PATCH] new schema to contain basic channel information --- server/migrations/2020-03-11-005217_channels/down.sql | 2 ++ server/migrations/2020-03-11-005217_channels/up.sql | 7 +++++++ server/src/models.rs | 10 +++++++++- server/src/schema.rs | 9 +++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 server/migrations/2020-03-11-005217_channels/down.sql create mode 100644 server/migrations/2020-03-11-005217_channels/up.sql diff --git a/server/migrations/2020-03-11-005217_channels/down.sql b/server/migrations/2020-03-11-005217_channels/down.sql new file mode 100644 index 0000000..2bc8798 --- /dev/null +++ b/server/migrations/2020-03-11-005217_channels/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +DROP TABLE `channels`; \ No newline at end of file diff --git a/server/migrations/2020-03-11-005217_channels/up.sql b/server/migrations/2020-03-11-005217_channels/up.sql new file mode 100644 index 0000000..72d319d --- /dev/null +++ b/server/migrations/2020-03-11-005217_channels/up.sql @@ -0,0 +1,7 @@ +-- i32, String, i32 +CREATE TABLE IF NOT EXISTS `channels` ( + `id` INTEGER NOT NULL auto_increment, + `name` VARCHAR(255) NOT NULL, + `permissions` INTEGER NOT NULL, + PRIMARY KEY(`id`) +); \ No newline at end of file diff --git a/server/src/models.rs b/server/src/models.rs index 49eb2db..7691edc 100644 --- a/server/src/models.rs +++ b/server/src/models.rs @@ -1,4 +1,4 @@ -use crate::schema::{invites, users}; +use crate::schema::{invites, users, channels}; #[derive(Insertable, Serialize, Deserialize, Queryable, Debug)] #[table_name = "invites"] pub struct Invite { @@ -14,4 +14,12 @@ pub struct User { pub username: String, pub key: String, pub date: u64, +} + +#[derive(Serialize, Deserialize, Queryable, Insertable)] +#[table_name = "channels" ] +pub struct Channel { + pub id: i32, + pub name: String, + pub permissions: i32, } \ No newline at end of file diff --git a/server/src/schema.rs b/server/src/schema.rs index ad6813b..917fd49 100644 --- a/server/src/schema.rs +++ b/server/src/schema.rs @@ -1,3 +1,11 @@ +table! { + channels (id) { + id -> Integer, + name -> Varchar, + permissions -> Integer, + } +} + table! { invites (id) { id -> Unsigned, @@ -16,6 +24,7 @@ table! { } allow_tables_to_appear_in_same_query!( + channels, invites, users, );