-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗃️ db (sqlite.migration): Created the initial User and Credentials ta…
…bles with a bunch of "enum" checks
- Loading branch information
1 parent
75d0a75
commit 70e96fa
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
db/sqlite3/migrations/20240720002541_user_and_credentials_related_tables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |