-- Chattyness User Initialization Trigger
-- PostgreSQL 18
--
-- Trigger to initialize new users with default props and avatar.
-- Load via: psql -f schema/triggers/002_user_init.sql

\set ON_ERROR_STOP on

BEGIN;

-- =============================================================================
-- User Registration Trigger
-- =============================================================================
-- Automatically initializes new users with default props and avatar
-- when they are inserted into auth.users.
-- =============================================================================

CREATE TRIGGER trg_auth_users_initialize
    AFTER INSERT ON auth.users
    FOR EACH ROW
    EXECUTE FUNCTION auth.initialize_new_user_trigger();

COMMENT ON TRIGGER trg_auth_users_initialize ON auth.users IS
    'Initialize new users with default props and avatar on registration';

COMMIT;
