ST-2.1: Unify timeframe enum - Created ddl/00-global-types.sql with public.trading_timeframe - Marked trading.timeframe and market_data.timeframe as DEPRECATED ST-2.2: Resolve transaction_type conflict - Documented rename plan: financial.wallet_transaction_type - Documented rename plan: investment.investment_transaction_type - Added deprecation comments to both enums ST-2.3: Unify common functions - Created ddl/00-global-functions.sql with public.update_updated_at() - Marked schema-specific functions as DEPRECATED: - auth.update_updated_at() - education.update_updated_at_column() - financial.update_timestamp() - feature_flags.update_timestamp() Migrations created (not executed): - 2026-02-03_unify_timeframe_enum.sql - 2026-02-03_rename_transaction_type_enums.sql - 2026-02-03_unify_common_functions.sql Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
54 lines
1.7 KiB
PL/PgSQL
54 lines
1.7 KiB
PL/PgSQL
-- ============================================================================
|
|
-- OrbiQuant IA - Trading Platform
|
|
-- Schema: auth
|
|
-- File: functions/01-update_updated_at.sql
|
|
-- Description: Trigger function to automatically update updated_at timestamp
|
|
-- ============================================================================
|
|
-- DEPRECATED: Use public.update_updated_at() instead
|
|
-- Migration: migrations/2026-02-03_unify_common_functions.sql
|
|
-- Issue: DUP-003
|
|
-- Task: ST-2.3
|
|
-- ============================================================================
|
|
|
|
CREATE OR REPLACE FUNCTION auth.update_updated_at()
|
|
RETURNS TRIGGER AS $$
|
|
BEGIN
|
|
NEW.updated_at = NOW();
|
|
RETURN NEW;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
COMMENT ON FUNCTION auth.update_updated_at() IS 'Trigger function to automatically update updated_at column on row modification';
|
|
|
|
-- Apply trigger to all tables with updated_at column
|
|
|
|
-- Users table
|
|
CREATE TRIGGER trigger_update_users_updated_at
|
|
BEFORE UPDATE ON auth.users
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION auth.update_updated_at();
|
|
|
|
-- User profiles table
|
|
CREATE TRIGGER trigger_update_user_profiles_updated_at
|
|
BEFORE UPDATE ON auth.user_profiles
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION auth.update_updated_at();
|
|
|
|
-- OAuth accounts table
|
|
CREATE TRIGGER trigger_update_oauth_accounts_updated_at
|
|
BEFORE UPDATE ON auth.oauth_accounts
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION auth.update_updated_at();
|
|
|
|
-- Sessions table
|
|
CREATE TRIGGER trigger_update_sessions_updated_at
|
|
BEFORE UPDATE ON auth.sessions
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION auth.update_updated_at();
|
|
|
|
-- Rate limiting config table
|
|
CREATE TRIGGER trigger_update_rate_limiting_config_updated_at
|
|
BEFORE UPDATE ON auth.rate_limiting_config
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION auth.update_updated_at();
|