Created
December 27, 2024 20:02
-
-
Save Youka/119f842cedaec508f25a228a47094b02 to your computer and use it in GitHub Desktop.
Simple postgres script to create a users table
This file contains hidden or 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
CREATE TABLE IF NOT EXISTS users ( | |
id uuid PRIMARY KEY DEFAULT gen_random_uuid(), | |
name varchar(32) UNIQUE NOT NULL CHECK (length(name) >= 3), | |
avatar_file bytea STORAGE EXTERNAL CHECK (avatar_file IS NULL OR length(avatar_file) < 50000), | |
about_me varchar(2048), | |
date_time_creation timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'utc'), | |
date_time_last_login timestamp CHECK (date_time_last_login IS NULL OR date_time_last_login >= date_time_creation) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment