АДРЕСНЫЙ РЕЖИМ - ллм декомпоз

This commit is contained in:
2026-04-01 22:11:40 +03:00
parent 18e0f1364d
commit b2d32f869c
1540 changed files with 10464 additions and 1451 deletions
@@ -0,0 +1,47 @@
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE TABLE IF NOT EXISTS stations (
id SERIAL PRIMARY KEY,
provider_uid INTEGER NOT NULL UNIQUE,
name TEXT,
lat DOUBLE PRECISION,
lon DOUBLE PRECISION,
source_meta JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS measurements (
station_id INTEGER NOT NULL REFERENCES stations(id),
observed_ts TIMESTAMPTZ NOT NULL,
ingested_ts TIMESTAMPTZ NOT NULL DEFAULT NOW(),
aqi INTEGER,
raw JSONB,
PRIMARY KEY (station_id, observed_ts)
);
SELECT create_hypertable('measurements', 'observed_ts', if_not_exists => TRUE);
CREATE INDEX IF NOT EXISTS measurements_observed_ts_idx
ON measurements (observed_ts DESC);
CREATE INDEX IF NOT EXISTS measurements_station_ts_idx
ON measurements (station_id, observed_ts DESC);
CREATE TABLE IF NOT EXISTS anomalies (
id BIGSERIAL PRIMARY KEY,
station_id INTEGER REFERENCES stations(id),
type TEXT NOT NULL,
severity INTEGER,
confidence DOUBLE PRECISION,
ts_start TIMESTAMPTZ NOT NULL,
ts_end TIMESTAMPTZ,
metric TEXT,
evidence JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS anomalies_ts_start_idx
ON anomalies (ts_start DESC);
CREATE INDEX IF NOT EXISTS anomalies_station_ts_idx
ON anomalies (station_id, ts_start DESC);