Files
taiji-AI-PAD/services/mcp-server/migrations/010_add_agent_billing_fields.sql
T

37 lines
1.2 KiB
SQL

-- Migration: Add missing fields to agent_billing_records table
-- Version: 010
-- Date: 2026-01-07
-- Add is_platform_agent column
ALTER TABLE agent_billing_records
ADD COLUMN IF NOT EXISTS is_platform_agent BOOLEAN DEFAULT TRUE;
-- Add start_time column
ALTER TABLE agent_billing_records
ADD COLUMN IF NOT EXISTS start_time TIMESTAMP WITHOUT TIME ZONE;
-- Add end_time column
ALTER TABLE agent_billing_records
ADD COLUMN IF NOT EXISTS end_time TIMESTAMP WITHOUT TIME ZONE;
-- Make period_start and period_end nullable
ALTER TABLE agent_billing_records
ALTER COLUMN period_start DROP NOT NULL;
ALTER TABLE agent_billing_records
ALTER COLUMN period_end DROP NOT NULL;
-- Make cost have a default value
ALTER TABLE agent_billing_records
ALTER COLUMN cost SET DEFAULT 0;
-- Make template_name nullable
ALTER TABLE agent_billing_records
ALTER COLUMN template_name DROP NOT NULL;
-- Create index for is_platform_agent
CREATE INDEX IF NOT EXISTS idx_agent_billing_is_platform ON agent_billing_records(is_platform_agent);
-- Create index for end_time (for finding running agents)
CREATE INDEX IF NOT EXISTS idx_agent_billing_end_time ON agent_billing_records(end_time);