Files
sorsfonalak/crates/db/migrations/0015_forecasts.sql
T
fecoandClaude Opus 5.5 f1bd34c394
CI / test (push) Successful in 56s
CI / build (push) Successful in 4m41s
CI / deploy (push) Skipped
Yearly forecast: solar return, transits, progressions, profection, eclipses
- astro-engine: forecast module (solar return moment, slow-planet transits
  with exact dates and periods, natal house ingresses, secondary
  progressions, annual profection, eclipses via Swiss Ephemeris)
- horoscope-api: POST /v1/forecast, solar return chart cast for the place
  of the birthday
- backend: forecasts table, /v1/charts/{id}/forecasts, /v1/forecasts/{id}
  and its analyses using a new 'forecast' unit; current year of life open,
  the next one 30 days before the birthday
- packages: Páros and Család include forecasts (6 000 / 11 000 Ft),
  +1 éves előrejelzés add-on 2 500 Ft; Egy elemzés unchanged
- worker and prompt: forecast kind with five sections and forecast rules
  (trends, no event predictions); no birth data, place or exact age sent
- frontend: /kepletek/{id}/elorejelzes with the solar return wheel, the
  keys of the year, a monthly timeline, transit list and detailed forecast
- data export: forecasts added, model name removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-18 08:19:13 +00:00

40 lines
2.0 KiB
SQL

-- Yearly forecasts: one year of a chart from a solar return (birthday) to the
-- next, calculated by the horoscope service for where the person is on the
-- birthday. The calculation is free; its detailed text analysis (kind
-- 'forecast') uses a 'forecast' unit.
CREATE TABLE forecasts (
id uuid PRIMARY KEY,
chart_id uuid NOT NULL REFERENCES charts ON DELETE CASCADE,
-- The chart it was calculated from; a corrected birth data gives a new forecast.
chart_hash text NOT NULL,
-- Calendar year of the solar return that starts it.
year integer NOT NULL,
-- {country, place, geonames_id, ...}; NULL = the birth place.
location jsonb,
location_key text NOT NULL,
result jsonb NOT NULL,
forecast_hash text NOT NULL,
created_by uuid REFERENCES users ON DELETE SET NULL,
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (chart_id, chart_hash, year, location_key)
);
CREATE INDEX forecasts_chart_idx ON forecasts (chart_id, year DESC);
ALTER TABLE analyses ADD COLUMN forecast_id uuid REFERENCES forecasts ON DELETE CASCADE;
CREATE INDEX analyses_forecast_idx ON analyses (forecast_id, created_at DESC) WHERE forecast_id IS NOT NULL;
ALTER TABLE analyses DROP CONSTRAINT analyses_kind_check;
ALTER TABLE analyses ADD CONSTRAINT analyses_kind_check CHECK (kind IN ('natal', 'synastry', 'summary', 'forecast'));
ALTER TABLE analyses DROP CONSTRAINT analyses_target;
ALTER TABLE analyses ADD CONSTRAINT analyses_target CHECK (
(kind IN ('natal', 'summary') AND chart_id IS NOT NULL AND synastry_id IS NULL AND forecast_id IS NULL)
OR (kind = 'synastry' AND synastry_id IS NOT NULL AND chart_id IS NULL AND forecast_id IS NULL)
OR (kind = 'forecast' AND forecast_id IS NOT NULL AND chart_id IS NULL AND synastry_id IS NULL)
);
ALTER TABLE credit_ledger DROP CONSTRAINT credit_ledger_unit_check;
ALTER TABLE credit_ledger ADD CONSTRAINT credit_ledger_unit_check
CHECK (unit IN ('natal', 'synastry', 'forecast', 'person'));