-- =============================================================================
-- TRIGGERS PARA SCHEMA STORAGE
-- =============================================================================
-- Actualiza automaticamente la columna updated_at en las tablas del schema storage
-- Usa la funcion publica set_updated_at() definida en 03-functions.sql

-- Trigger para storage.files
CREATE TRIGGER trg_files_updated_at
    BEFORE UPDATE ON storage.files
    FOR EACH ROW
    EXECUTE FUNCTION public.set_updated_at();

-- Trigger para storage.usage
CREATE TRIGGER trg_usage_updated_at
    BEFORE UPDATE ON storage.usage
    FOR EACH ROW
    EXECUTE FUNCTION public.set_updated_at();

-- Comments
COMMENT ON TRIGGER trg_files_updated_at ON storage.files IS 'Auto-update updated_at timestamp on file record changes';
COMMENT ON TRIGGER trg_usage_updated_at ON storage.usage IS 'Auto-update updated_at timestamp on usage record changes';
