Files
online-backend/db/migrations/20260813141500_registration_verifications.up.sql

22 lines
876 B
SQL

CREATE TABLE IF NOT EXISTS registration_verifications (
id bigserial PRIMARY KEY,
name character varying(255) NOT NULL DEFAULT '',
username character varying(250) NOT NULL DEFAULT '',
phone character varying(250) NOT NULL,
password character varying(250) NOT NULL DEFAULT '',
code_hash character varying(250) NOT NULL DEFAULT '',
attempts integer NOT NULL DEFAULT 0,
expires_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
CONSTRAINT registration_verifications_phone_key UNIQUE (phone)
);
CREATE UNIQUE INDEX IF NOT EXISTS users_username_unique
ON users (LOWER(username))
WHERE username <> '';
CREATE UNIQUE INDEX IF NOT EXISTS users_phone_unique
ON users (phone)
WHERE phone <> '';