
    JjQ                     8    d Z ddlmZ dZdZdZdZdZd	dZd	dZ	y)
a   Phrase library: sentences from past bottom lines and problem discussions.

Built from `forecasts` / `forecast_problems` by app.phrases.rebuild, so any
source that lands in those tables (Drupal archive now; NAC/AFP later) feeds it.

Revision ID: 0003
Revises: 0002
Create Date: 2026-09-18
    )op00030002Na>  
CREATE TABLE phrases (
    id bigserial PRIMARY KEY,
    center_id integer NOT NULL REFERENCES centers(id) ON DELETE CASCADE,
    forecast_id integer NOT NULL REFERENCES forecasts(id) ON DELETE CASCADE,
    field text NOT NULL CHECK (field IN ('bottom_line', 'problem')),
    problem_types smallint[] NOT NULL DEFAULT '{}',
    likelihood smallint,
    size_max numeric(2,1),
    locations text[] NOT NULL DEFAULT '{}',
    text text NOT NULL,
    norm text NOT NULL,
    valid_date date NOT NULL,
    source text NOT NULL,
    guidance_era text NOT NULL,
    tsv tsvector GENERATED ALWAYS AS (to_tsvector('english', text)) STORED
);
CREATE INDEX phrases_center_field_idx ON phrases (center_id, field);
CREATE INDEX phrases_types_idx ON phrases USING gin (problem_types);
CREATE INDEX phrases_tsv_idx ON phrases USING gin (tsv);
c                  6    t        j                  t               y )N)r   executeUPGRADE     :/var/www/avy-guidance/api/alembic/versions/0003_phrases.pyupgrader   )   s    JJwr
   c                  .    t        j                  d       y )NzDROP TABLE phrases)r   r   r	   r
   r   	downgrader   -   s    JJ#$r
   )returnN)
__doc__alembicr   revisiondown_revisionbranch_labels
depends_onr   r   r   r	   r
   r   <module>r      s4    
.%r
   