You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
synctv/migrations/20260426005_create_auth_ema...

14 lines
673 B
MySQL

CREATE TABLE IF NOT EXISTS auth_email_tokens (
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
token VARCHAR(255) UNIQUE NOT NULL,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
token_type SMALLINT NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
used_at TIMESTAMPTZ NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_auth_email_tokens_user_id ON auth_email_tokens(user_id);
CREATE INDEX IF NOT EXISTS idx_auth_email_tokens_type_expires ON auth_email_tokens(token_type, expires_at);
CREATE INDEX IF NOT EXISTS idx_auth_email_tokens_expires_at ON auth_email_tokens(expires_at);