16 lines
537 B
MySQL
16 lines
537 B
MySQL
|
|
-- 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';
|