From cdc88b836542ecd4da7d814a786c1eb4a458d85c Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 4 Jul 2020 22:52:59 -0700 Subject: [PATCH] * fixed formating/comments in users schema * channels schema now uses a bigint unsigned for pid this is to keep consistent with notion of id's being usize|u64 in rust * foreign key constraint added to keys table referencing user rows --- server/migrations/2020-02-04-083551_users/up.sql | 11 +++++------ server/migrations/2020-03-11-005217_channels/up.sql | 2 +- server/migrations/2020-06-02-055256_keys/up.sql | 6 ++++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/migrations/2020-02-04-083551_users/up.sql b/server/migrations/2020-02-04-083551_users/up.sql index b67a006..ac2f664 100644 --- a/server/migrations/2020-02-04-083551_users/up.sql +++ b/server/migrations/2020-02-04-083551_users/up.sql @@ -1,13 +1,12 @@ -- id: simple id tracking users --- username: default name that users have to display --- display: used as a non-unique eye candy for users --- password: yea --- email: used for signing in to the server +-- name: default name that users have to display +-- date: date that they signed up +-- status: online/offline/away etc. + CREATE TABLE IF NOT EXISTS `users` ( `id` bigint UNSIGNED NOT NULL auto_increment, `name` varchar(255) NOT NULL, - `secret` varchar(255) NOT NULL, `date` bigint UNSIGNED NOT NULL, - `status` int NOT NULL, + `status` integer NOT NULL, PRIMARY KEY( `id` ) ); \ 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 index 1579fa0..f7d6d7a 100644 --- a/server/migrations/2020-03-11-005217_channels/up.sql +++ b/server/migrations/2020-03-11-005217_channels/up.sql @@ -1,5 +1,5 @@ CREATE TABLE IF NOT EXISTS `channels` ( - `id` INTEGER NOT NULL auto_increment, + `id` BIGINT UNSIGNED NOT NULL auto_increment, `name` VARCHAR(255) NOT NULL, `description` VARCHAR(1024), `kind` INTEGER NOT NULL, diff --git a/server/migrations/2020-06-02-055256_keys/up.sql b/server/migrations/2020-06-02-055256_keys/up.sql index 652a2ab..e4720ed 100644 --- a/server/migrations/2020-06-02-055256_keys/up.sql +++ b/server/migrations/2020-06-02-055256_keys/up.sql @@ -3,8 +3,10 @@ -- Limits that are null just mean the limit does not exist CREATE TABLE IF NOT EXISTS `keys`( - `id` varchar(64) NOT NULL, + `secret` varchar(255) NOT NULL, `limit` integer, `uses` integer, - PRIMARY KEY(`id`) + `userid` bigint unsigned NOT NULL, + PRIMARY KEY(`secret`), + FOREIGN KEY `userid` REFERENCES users(`id`) ); \ No newline at end of file