forked from gorb/backend
feat: use diesel-cli instead of hand writing tables
after reading the documentation, crazy right? I figured out i was making my life hard, this makes my life easy again
This commit is contained in:
parent
f1d5b4316e
commit
a6d35b0ba2
24 changed files with 323 additions and 206 deletions
20
migrations/2025-05-21-192435_create_users/up.sql
Normal file
20
migrations/2025-05-21-192435_create_users/up.sql
Normal file
|
@ -0,0 +1,20 @@
|
|||
-- Your SQL goes here
|
||||
CREATE TABLE users (
|
||||
uuid uuid PRIMARY KEY NOT NULL,
|
||||
username varchar(32) NOT NULL,
|
||||
display_name varchar(64) DEFAULT NULL,
|
||||
password varchar(512) NOT NULL,
|
||||
email varchar(100) NOT NULL,
|
||||
email_verified boolean NOT NULL DEFAULT FALSE,
|
||||
is_deleted boolean NOT NULL DEFAULT FALSE,
|
||||
deleted_at int8 DEFAULT NULL,
|
||||
CONSTRAINT unique_username_active UNIQUE NULLS NOT DISTINCT (username, is_deleted),
|
||||
CONSTRAINT unique_email_active UNIQUE NULLS NOT DISTINCT (email, is_deleted)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX idx_unique_username_active
|
||||
ON users(username)
|
||||
WHERE is_deleted = FALSE;
|
||||
CREATE UNIQUE INDEX idx_unique_email_active
|
||||
ON users(email)
|
||||
WHERE is_deleted = FALSE;
|
Loading…
Add table
Add a link
Reference in a new issue