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.
32 lines
1.6 KiB
SQL
32 lines
1.6 KiB
SQL
CREATE TABLE IF NOT EXISTS auth_oauth2_identities (
|
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
provider VARCHAR(50) NOT NULL,
|
|
provider_user_id VARCHAR(255) NOT NULL,
|
|
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
|
|
username VARCHAR(255) NOT NULL,
|
|
email VARCHAR(255),
|
|
avatar_url TEXT,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT auth_oauth2_identities_provider_subject_unique
|
|
UNIQUE(provider, provider_user_id)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_auth_oauth2_identities_user_id ON auth_oauth2_identities(user_id);
|
|
CREATE INDEX IF NOT EXISTS idx_auth_oauth2_identities_provider ON auth_oauth2_identities(provider);
|
|
|
|
CREATE TRIGGER update_auth_oauth2_identities_updated_at
|
|
BEFORE UPDATE ON auth_oauth2_identities
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION update_updated_at_column();
|
|
|
|
COMMENT ON TABLE auth_oauth2_identities IS 'OAuth2/OIDC provider identity mappings';
|
|
COMMENT ON COLUMN auth_oauth2_identities.id IS 'numeric identity ID';
|
|
COMMENT ON COLUMN auth_oauth2_identities.provider IS 'OAuth2/OIDC provider name';
|
|
COMMENT ON COLUMN auth_oauth2_identities.provider_user_id IS 'User ID from OAuth2 provider';
|
|
COMMENT ON COLUMN auth_oauth2_identities.user_id IS 'Reference to local user';
|
|
COMMENT ON COLUMN auth_oauth2_identities.username IS 'Username from OAuth2 provider';
|
|
COMMENT ON COLUMN auth_oauth2_identities.email IS 'Email from OAuth2 provider (optional)';
|
|
COMMENT ON COLUMN auth_oauth2_identities.avatar_url IS 'Avatar URL from OAuth2 provider (optional)';
|