This commit is contained in:
Imbus 2024-03-17 16:04:23 +01:00
parent 2194204a58
commit db687b2600
2 changed files with 0 additions and 0 deletions

14
Migrations/0010_users.sql Normal file
View file

@ -0,0 +1,14 @@
-- Id is a surrogate key for in ternal use
-- userId is what is used for external id
-- username is what is used for login
-- password is the hashed password
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
userId TEXT DEFAULT (HEX(RANDOMBLOB(4))) NOT NULL UNIQUE,
username VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
);
-- Users are commonly searched by username and userId
CREATE INDEX IF NOT EXISTS users_username_index ON users (username);
CREATE INDEX IF NOT EXISTS users_userId_index ON users (userId);

View file

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS projects (
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
description TEXT NOT NULL,
owner_user_id INTEGER NOT NULL,
FOREIGN KEY (owner_user_id) REFERENCES users (id)
);
CREATE INDEX IF NOT EXISTS projects_user_id_index ON projects (owner_user_id);