13 lines
501 B
SQL
13 lines
501 B
SQL
CREATE TABLE weather_observations (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
observed_at TIMESTAMPTZ NOT NULL,
|
|
wind_speed_mph DECIMAL(5,2) NOT NULL,
|
|
wind_direction INTEGER NOT NULL CHECK (wind_direction >= 0 AND wind_direction < 360),
|
|
wind_gust_mph DECIMAL(5,2),
|
|
source VARCHAR(50) DEFAULT 'open-meteo',
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
UNIQUE (observed_at, source)
|
|
);
|
|
|
|
CREATE INDEX idx_weather_time ON weather_observations (observed_at DESC);
|