-- Migration: Create portfolio_allocations table
-- Purpose: Store portfolio allocation strategies and results
-- Agent: 11.15 - Portfolio Allocation Module

CREATE TABLE IF NOT EXISTS portfolio_allocations (
    allocation_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    allocation_data JSONB NOT NULL,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Index for fast lookups
CREATE INDEX IF NOT EXISTS idx_portfolio_allocations_created_at ON portfolio_allocations(created_at DESC);

-- Add comments for documentation
COMMENT ON TABLE portfolio_allocations IS 'Portfolio allocation strategies and results';
COMMENT ON COLUMN portfolio_allocations.allocation_id IS 'Unique allocation identifier (UUID)';
COMMENT ON COLUMN portfolio_allocations.allocation_data IS 'Full allocation details in JSON format';
COMMENT ON COLUMN portfolio_allocations.created_at IS 'When allocation was created';
COMMENT ON COLUMN portfolio_allocations.updated_at IS 'When allocation was last updated';
