Skip to content

Commit

Permalink
🗃️ db (sqlite.migration): Created the initial User and Credentials ta…
Browse files Browse the repository at this point in the history
…bles with a bunch of "enum" checks
  • Loading branch information
kevinmarquesp committed Jul 20, 2024
1 parent 75d0a75 commit 70e96fa
Showing 1 changed file with 36 additions and 0 deletions.
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

0 comments on commit 70e96fa

Please sign in to comment.