fixing schema after some more thought

This commit is contained in:
2026-01-12 14:10:13 -07:00
parent 8fb0ce7e08
commit f9bcdf6ef9

View File

@@ -1,17 +1,13 @@
DROP TABLE IF EXISTS periods; DROP TABLE IF EXISTS current_forecasts;
DROP TABLE IF EXISTS reports; DROP TABLE IF EXISTS daily_forecasts;
CREATE TABLE "periods" ( CREATE TABLE "current_forecasts" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT, "id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"report_id" Integer NOT NULL,
"period_number" Integer NOT NULL,
"start_time" DateTime NOT NULL, "start_time" DateTime NOT NULL,
"end_time" DateTime NOT NULL, "end_time" DateTime NOT NULL,
"is_daytime" Integer NOT NULL, "is_daytime" Integer NOT NULL,
"temperature" Integer NOT NULL, "temperature" Integer NOT NULL,
"temperature_unit" Text NOT NULL DEFAULT 'F',
"precipitation_probability" Integer, "precipitation_probability" Integer,
"dewpoint_celsius" Numeric,
"relative_humidity" Integer, "relative_humidity" Integer,
"wind_speed" Text, "wind_speed" Text,
"wind_direction" Text, "wind_direction" Text,
@@ -19,24 +15,17 @@ CREATE TABLE "periods" (
"short_forecast" Text, "short_forecast" Text,
"detailed_forecast" Text, "detailed_forecast" Text,
"created_at" DateTime, "created_at" DateTime,
"updated_at" DateTime, "updated_at" DateTime
CONSTRAINT "periods_reports_CASCADE_NO ACTION_report_id_id_0" FOREIGN KEY ( "report_id" ) REFERENCES "reports"( "id" )
ON DELETE Cascade
); );
CREATE INDEX "periods_report_id_start_time_index" ON "periods"( "report_id", "start_time" ); CREATE TABLE "daily_forecasts" (
CREATE TABLE "reports" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT, "id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"type" Text NOT NULL, "forecasted_date" DateTime NOT NULL,
"reported_at" DateTime NOT NULL, "temperature_high" Integer NOT NULL,
"generated_at" DateTime NOT NULL, "precipitation_probability" Integer,
"latitude" Numeric NOT NULL, "icon_url" Text,
"longitude" Numeric NOT NULL, "short_forecast" Text,
"elevation_meters" Numeric,
"created_at" DateTime, "created_at" DateTime,
"updated_at" DateTime, "updated_at" DateTime
CONSTRAINT "check ""type"" in ('hourly', 'weekly')" CHECK ("type" in ('hourly', 'weekly')) ); );
CREATE INDEX "reports_type_reported_at_index" ON "reports"( "type", "reported_at" );
CREATE UNIQUE INDEX "reports_type_reported_at_unique" ON "reports"( "type", "reported_at" );