cosmo/backend/migrations/add_nasa_horizons_cron_sour...

16 lines
537 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- Migration: 添加 nasa_horizons_cron 到 positions 表的 source 约束
-- Date: 2025-12-11
-- 1. 删除旧的约束
ALTER TABLE positions DROP CONSTRAINT IF EXISTS chk_source;
-- 2. 添加新的约束(包含 nasa_horizons_cron
ALTER TABLE positions ADD CONSTRAINT chk_source
CHECK (source IN ('nasa_horizons', 'nasa_horizons_cron', 'calculated', 'user_defined', 'imported'));
-- 3. 验证约束
SELECT conname, pg_get_constraintdef(oid)
FROM pg_constraint
WHERE conrelid = 'positions'::regclass
AND conname = 'chk_source';