trading-platform-database-v2/ddl/00-global-types.sql
Adrian Flores Cortes f64251e459 [TASK-2026-02-03-ANALISIS-DDL-MODELADO] refactor(ddl): FASE-2 Conflicts & Duplications
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>
2026-02-03 23:51:08 -06:00

47 lines
1.8 KiB
SQL

-- ============================================================================
-- File: 00-global-types.sql
-- Description: Global Types - Used across all schemas
-- Location: public schema
-- Created: 2026-02-03
-- Task: ST-2.1 - Unificar enum timeframe en schema publico
-- ============================================================================
-- These types are created in the public schema and should be used by all
-- schema-specific tables that require these common types.
-- ============================================================================
-- TIMEFRAME ENUM (Unified)
-- ============================================================================
-- Unified timeframe for trading operations
-- Superset of all values from trading.timeframe and market_data.timeframe
--
-- Usage:
-- Instead of trading.timeframe or market_data.timeframe
-- Use: public.trading_timeframe
--
-- Migration path for existing tables:
-- See: migrations/2026-02-03_unify_timeframe_enum.sql
CREATE TYPE public.trading_timeframe AS ENUM (
'1m', -- 1 minute
'5m', -- 5 minutes
'15m', -- 15 minutes
'30m', -- 30 minutes
'1h', -- 1 hour
'4h', -- 4 hours
'1d', -- 1 day
'1w', -- 1 week
'1M' -- 1 month
);
COMMENT ON TYPE public.trading_timeframe IS 'Standard timeframes for charts and trading data. Unified type replacing trading.timeframe and market_data.timeframe';
-- ============================================================================
-- FUTURE GLOBAL TYPES
-- ============================================================================
-- Add additional global types here as needed. Candidates for unification:
-- - Currency codes (if needed across schemas)
-- - Common status enums
-- - Measurement units
-- ============================================================================