mirror of https://github.com/synctv-org/synctv
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.
27 lines
1017 B
MySQL
27 lines
1017 B
MySQL
|
2 months ago
|
CREATE TABLE IF NOT EXISTS auth_email_identities (
|
||
|
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||
|
|
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||
|
|
email VARCHAR(255) NOT NULL,
|
||
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
|
||
|
|
CONSTRAINT auth_email_identities_user_unique
|
||
|
|
UNIQUE(user_id),
|
||
|
|
CONSTRAINT auth_email_identities_email_not_empty
|
||
|
|
CHECK (length(trim(email)) > 0)
|
||
|
|
);
|
||
|
|
|
||
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_auth_email_identities_email_lower
|
||
|
|
ON auth_email_identities(LOWER(email));
|
||
|
|
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_auth_email_identities_user_id
|
||
|
|
ON auth_email_identities(user_id);
|
||
|
|
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_auth_email_identities_email_trgm
|
||
|
|
ON auth_email_identities USING gin(email gin_trgm_ops);
|
||
|
|
|
||
|
|
CREATE TRIGGER update_auth_email_identities_updated_at
|
||
|
|
BEFORE UPDATE ON auth_email_identities
|
||
|
|
FOR EACH ROW
|
||
|
|
EXECUTE FUNCTION update_updated_at_column();
|