From 70e96fa21d87ebd1e600df2e2e72643c570cedd3 Mon Sep 17 00:00:00 2001 From: Kevin Marques Date: Fri, 19 Jul 2024 22:05:45 -0300 Subject: [PATCH] :card_file_box: db (sqlite.migration): Created the initial User and Credentials tables with a bunch of "enum" checks --- ...41_user_and_credentials_related_tables.sql | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 db/sqlite3/migrations/20240720002541_user_and_credentials_related_tables.sql diff --git a/db/sqlite3/migrations/20240720002541_user_and_credentials_related_tables.sql b/db/sqlite3/migrations/20240720002541_user_and_credentials_related_tables.sql new file mode 100644 index 0000000..17986b1 --- /dev/null +++ b/db/sqlite3/migrations/20240720002541_user_and_credentials_related_tables.sql @@ -0,0 +1,36 @@ +-- +goose Up +-- +goose StatementBegin +CREATE TABLE Users ( + id TEXT UNIQUE NOT NULL CHECK (LENGTH(id) = 26), + name TEXT, + username TEXT UNIQUE NOT NULL, + email TEXT UNIQUE NOT NULL, + description TEXT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + + auth_type TEXT CHECK ( + auth_type IS 'CREDENTIALS' OR + auth_type IS 'ANONYMOUS' OR + auth_type IS 'GOOGLE' OR + auth_type IS 'GITHUB' + ), + + role TEXT DEFAULT 'STANDARD' CHECK ( + role IS 'STANDARD' OR + role IS 'MODERATOR' OR + role IS 'BANNED' + ) +); + +CREATE TABLE Credentials ( + userId TEXT UNIQUE NOT NULL CHECK (LENGTH(userId) = 26), + password TEXT NOT NULL CHECK (LENGTH(password) >= 60) +); +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +DROP TABLE Users; +DROP TABLE Credentials; +-- +goose StatementEnd