Started writing auth sql schema

pull/36/head
Jef Roosens 2021-08-20 14:06:01 +02:00
parent fcd31fd6a8
commit 4ccee64323
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
4 changed files with 27 additions and 5 deletions

View File

@ -15,11 +15,18 @@ path = "src/rbs/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
# Backend web framework
rocket = "0.5.0-rc.1" rocket = "0.5.0-rc.1"
# ORM
diesel = { version = "1.4.7", features = ["postgres"] } diesel = { version = "1.4.7", features = ["postgres"] }
diesel_migrations = "1.4.0" diesel_migrations = "1.4.0"
# To properly compile libpq statically
openssl = "0.10.36" openssl = "0.10.36"
# For password hashing & verification
rust-argon2 = "0.8.3"
rand = "0.8.4"
# Used to provide Rocket routes with database connections
[dependencies.rocket_sync_db_pools] [dependencies.rocket_sync_db_pools]
version = "0.1.0-rc.1" version = "0.1.0-rc.1"
default_features = false default_features = false

View File

@ -0,0 +1 @@
-- This file should undo anything in `up.sql`

View File

@ -0,0 +1,17 @@
-- Users
CREATE TABLE users (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
username varchar(32) UNIQUE NOT NULL,
password text NOT NULL
);
-- Permissions that a user can have
CREATE TABLE permissions (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
user_id uuid REFERENCES users (id) NOT NULL,
name varchar NOT NULL,
UNIQUE (user_id, name)
);

View File

@ -2,11 +2,8 @@
// compilation succeeds // compilation succeeds
extern crate openssl; extern crate openssl;
#[macro_use] #[macro_use] extern crate rocket;
extern crate rocket; #[macro_use] extern crate diesel_migrations;
#[macro_use]
extern crate diesel_migrations;
use rocket::{fairing::AdHoc, Build, Rocket}; use rocket::{fairing::AdHoc, Build, Rocket};
use rocket_sync_db_pools::{database, diesel}; use rocket_sync_db_pools::{database, diesel};