Commit Graph

15 Commits

Author SHA1 Message Date
Adrian Flores Cortes
86112cf73a [REMEDIATION] fix: Update trading enums and price_alerts table DDL
Add missing enum values to trading schema and refactor price_alerts table
structure to align with backend types. Addresses DDL gaps from analysis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:17:19 -06:00
Adrian Flores Cortes
45d5825bb3 docs(database): Add timestamp standardization plan and migration template
- Document current TIMESTAMPTZ compliance across all schemas
- Create comprehensive migration template for future use
- Include validation queries and best practices
- Add examples for different timezone scenarios
2026-02-04 00:01:32 -06:00
Adrian Flores Cortes
83fa4d3295 [ST-4.2] feat: Add soft delete to education.course_reviews
- Added deleted_at and deleted_by columns for soft delete functionality
- Created migration 002-add_course_reviews_soft_delete.sql
- Added indexes for efficient active reviews queries
- Updated DDL schema definition with new columns and comments
- Gap: GAP-010

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:57:00 -06:00
Adrian Flores Cortes
82d6e608b1 [ST-4.1] feat: Add optimized partial index for auth.users.locked_until
- Create migration 2026-02-03_add_auth_locked_index.sql
- Add partial index on locked_until with active lockout condition
- Replace previous generic locked_until index with optimized version
- Index filters for locked_until IS NOT NULL AND locked_until > NOW()
- Improves query performance for account unlock validation
- Resolves GAP-009

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:56:26 -06:00
Adrian Flores Cortes
6da2786590 [TASK-2026-02-03-ANALISIS-DDL-MODELADO] feat(ddl): FASE-3 Moderate P1 gaps
ST-3.1: Course tags system
- education.course_tags with slug, color, featured flag
- education.course_tag_assignments (M:N) with auto usage_count
- Seeds: 10 initial tags (forex, crypto, ICT, etc.)

ST-3.2: Drawing tools for charts
- Enum: trading.drawing_tool_type (18 types including ICT)
- trading.drawing_tools with JSONB points and styles
- trading.drawing_templates for reusable presets

ST-3.3: Complete agent_executions
- Added 10 columns: execution_time_ms, slippage, risk_score, etc.
- 5 new performance indexes
- Trigger for updated_at

ST-3.4: ML composite indexes
- 8 new composite/partial indexes for predictions
- Optimized for symbol+timeframe+date queries
- Partial indexes for high confidence and overlay display

New files: 7 DDL, 2 migrations, 1 seed
Modified: 3 existing DDL files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:55:24 -06:00
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
Adrian Flores Cortes
c651fe5a30 [TASK-2026-02-03-ANALISIS-DDL-MODELADO] feat(ddl): FASE-1 Gaps Críticos P0
ST-1.1: financial.refunds - Already exists with approval flow
ST-1.2: education.instructors - Created with GIN indexes
ST-1.3: trading.price_alerts - FK exists, idempotent migration added
ST-1.4: ml.prediction_overlays - New table + overlay columns

New files:
- ddl/schemas/education/tables/17-instructors.sql
- ddl/schemas/ml/tables/12-prediction_overlays.sql
- migrations/2026-02-03_add_predictions_overlay.sql
- migrations/2026-02-03_add_price_alerts_symbol_fk.sql

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:45:39 -06:00
Adrian Flores Cortes
e4d39b1293 [Sprint-2] feat: Add Feature Flags schema
Created feature_flags schema with:
- flags table: Global feature flag definitions
- user_flags table: User-level overrides
- evaluations table: Evaluation history for analytics
- evaluate_flag() function: PL/pgSQL evaluation with priorities

Features:
- Percentage-based rollout
- User override support
- Targeting rules (plan, role)
- Expiration support
- Initial flags for trading platform

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:38:38 -06:00
Adrian Flores Cortes
2a6d8367d8 feat: Update DDL schemas and add new structures
DDL updates:
- Update extensions and schemas configuration
- Add sessions table for auth schema
- Update education schema (videos, install/uninstall scripts)
- Add backtest_runs and llm_signals tables for ML schema

Scripts:
- Update database creation and migration scripts
- Add DDL validation script

New:
- Add migrations directory structure
- Add production seeds for auth, investment, market_data, trading

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 12:24:23 -06:00
Adrian Flores Cortes
70c201da8e feat: Add review_helpful_votes table (OQI-002)
Created table to track user votes on course reviews:
- education.review_helpful_votes
- Constraint: one vote per user per review
- Indexes on user_id and review_id

This table supports the "mark as helpful" feature in course reviews.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 12:40:21 -06:00
Adrian Flores Cortes
551091d26a feat(database): Add GBPJPY ticker to market_data seed data
- Add GBPJPY (GBP/JPY, forex, C:GBPJPY) to tickers seed
- Now 7 tickers: XAUUSD, EURUSD, BTCUSD, GBPUSD, USDJPY, AUDUSD, GBPJPY

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 04:39:41 -06:00
Adrian Flores Cortes
3f7816d4ec feat(database): Add videos table for education module (ST4.3.1)
Table: education.videos

Features:
- Multipart upload tracking (upload_id, parts, progress)
- Storage integration (S3/R2/Cloudflare Stream)
- Video processing status (uploading → processing → ready)
- Transcoded versions JSONB (multiple resolutions)
- CDN URLs (video + thumbnail)
- Metadata JSONB (tags, language, difficulty, captions, transcript)
- Soft delete (deleted_at)
- GIN index for metadata search
- Helper functions (soft_delete_video)
- View for active videos

Constraints:
- Valid status enum
- Valid storage provider enum
- Positive file size & duration
- Progress 0-100%

Blocker: BLOCKER-003 (ST4.3 Video Upload Backend)
Epic: OQI-002

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 20:06:10 -06:00
Adrian Flores Cortes
3fbb1c21e6 [OQI-008] feat: Add portfolio DDL schema with tables for portfolios, allocations, goals
- Added portfolio schema to 01-schemas.sql
- Created enums: risk_profile, goal_status, rebalance_action, allocation_status
- Created tables: portfolios, portfolio_allocations, portfolio_goals
- Created tables: rebalance_history, portfolio_snapshots
- Added triggers for updated_at and goal progress calculations
- Added indexes for performance

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:20:48 -06:00
Adrian Flores Cortes
439489bde4 feat: Add DDL tables for notifications system
- Add auth.notifications table for storing user notifications
- Add auth.user_push_tokens table for FCM/APNs tokens
- Add investment.distribution_history for daily distribution records
- Add investment.distribution_runs for job execution logs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 03:48:28 -06:00
45e77e9a9c feat: Initial commit - Database schemas and scripts
DDL schemas for Trading Platform:
- User management
- Authentication
- Payments
- Education
- ML predictions
- Trading data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 04:30:23 -06:00