106_add_account_stats_pricing_intervals.sql 953 B

12345678910111213141516171819
  1. -- Add intervals table for account stats pricing rules (mirrors channel_pricing_intervals).
  2. CREATE TABLE IF NOT EXISTS channel_account_stats_pricing_intervals (
  3. id BIGSERIAL PRIMARY KEY,
  4. pricing_id BIGINT NOT NULL REFERENCES channel_account_stats_model_pricing(id) ON DELETE CASCADE,
  5. min_tokens INT NOT NULL DEFAULT 0,
  6. max_tokens INT,
  7. tier_label VARCHAR(50),
  8. input_price NUMERIC(20,12),
  9. output_price NUMERIC(20,12),
  10. cache_write_price NUMERIC(20,12),
  11. cache_read_price NUMERIC(20,12),
  12. per_request_price NUMERIC(20,12),
  13. sort_order INT NOT NULL DEFAULT 0,
  14. created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  15. updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
  16. );
  17. CREATE INDEX IF NOT EXISTS idx_account_stats_pricing_intervals_pricing_id
  18. ON channel_account_stats_pricing_intervals (pricing_id);