diff --git a/etl-pipeline/custom/create_table_airnow_readings.sql b/etl-pipeline/custom/create_table_airnow_readings.sql index 68ef9e8..40ecf12 100644 --- a/etl-pipeline/custom/create_table_airnow_readings.sql +++ b/etl-pipeline/custom/create_table_airnow_readings.sql @@ -1,4 +1,4 @@ --- Docs: https://docs.mage.ai/guides/sql-blocks + CREATE TABLE IF NOT EXISTS airnow_readings_bronze( id SERIAL PRIMARY KEY, station_id INTEGER REFERENCES stations(id), -- constrain: is_pattern_station == True diff --git a/etl-pipeline/custom/create_table_region_readings.sql b/etl-pipeline/custom/create_table_region_readings.sql index 92f2e45..ad8387a 100644 --- a/etl-pipeline/custom/create_table_region_readings.sql +++ b/etl-pipeline/custom/create_table_region_readings.sql @@ -1,7 +1,7 @@ CREATE TABLE IF NOT EXISTS region_readings( id SERIAL PRIMARY KEY, date_utc TIMESTAMP WITH TIME ZONE, - region INTEGER REFERENCES regions(id), + region_id INTEGER REFERENCES regions(id), pm2_5_region_avg FLOAT, pm2_5_region_max FLOAT, pm2_5_region_skew FLOAT, @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS region_readings( aqi_region_skew FLOAT, aqi_region_std FLOAT, level_region_max FLOAT, - UNIQUE (region, date_utc) + UNIQUE (region_id, date_utc) ); -- CREATE TABLE IF NOT EXISTS station_readings_gold_to_region ( diff --git a/etl-pipeline/custom/create_table_station_readings.sql b/etl-pipeline/custom/create_table_station_readings.sql index 9ae9606..87ade76 100644 --- a/etl-pipeline/custom/create_table_station_readings.sql +++ b/etl-pipeline/custom/create_table_station_readings.sql @@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS station_readings_silver ( CREATE TABLE IF NOT EXISTS station_readings_gold ( id SERIAL PRIMARY KEY, - station INTEGER REFERENCES stations(id), + station_id INTEGER REFERENCES stations(id), airnow_id INTEGER REFERENCES airnow_readings_silver(id) NULL, date_utc TIMESTAMP WITH TIME ZONE, pm_calibrated BOOLEAN, @@ -51,7 +51,7 @@ CREATE TABLE IF NOT EXISTS station_readings_gold ( aqi_pm2_5_skew_24h FLOAT, aqi_pm2_5_std_24h FLOAT, processed_to_region BOOLEAN DEFAULT FALSE, - UNIQUE (station, date_utc) + UNIQUE (station_id, date_utc) ); -- CREATE TABLE IF NOT EXISTS station_readings_gold_to_silver ( diff --git a/etl-pipeline/custom/create_table_stations.sql b/etl-pipeline/custom/create_table_stations.sql index 01ada9d..1a13653 100644 --- a/etl-pipeline/custom/create_table_stations.sql +++ b/etl-pipeline/custom/create_table_stations.sql @@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS stations ( name VARCHAR, latitude FLOAT, longitude FLOAT, - region INTEGER REFERENCES regions(id), + region_id INTEGER REFERENCES regions(id), is_station_on BOOLEAN, is_pattern_station BOOLEAN ); @@ -15,7 +15,7 @@ INSERT INTO stations ( name, latitude, longitude, - region, + region_id, is_station_on, is_pattern_station ) VALUES @@ -38,7 +38,7 @@ INSERT INTO stations ( name, latitude, longitude, - region, + region_id, is_station_on, is_pattern_station ) VALUES diff --git a/etl-pipeline/custom/create_table_weather_readings.sql b/etl-pipeline/custom/create_table_weather_readings.sql index 902f3f2..438f88d 100644 --- a/etl-pipeline/custom/create_table_weather_readings.sql +++ b/etl-pipeline/custom/create_table_weather_readings.sql @@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS weather_readings_gold ( weather_station INTEGER REFERENCES weather_stations(id), date_localtime TIMESTAMP WITH TIME ZONE, temperature FLOAT, - humidity FLOAT, + humidity FLOAT, pressure FLOAT, wind_speed FLOAT, wind_dir_cos FLOAT, diff --git a/etl-pipeline/custom/create_tables_inference.sql b/etl-pipeline/custom/create_tables_inference.sql index 1f257a5..158da2f 100644 --- a/etl-pipeline/custom/create_tables_inference.sql +++ b/etl-pipeline/custom/create_tables_inference.sql @@ -6,8 +6,8 @@ CREATE TABLE IF NOT EXISTS inference_runs ( CREATE TABLE IF NOT EXISTS inference_results ( id SERIAL PRIMARY KEY, - inference_run INTEGER REFERENCES inference_runs(id), - station INTEGER REFERENCES stations(id), + inference_run_id INTEGER REFERENCES inference_runs(id), + station_id INTEGER REFERENCES stations(id), forecasts_6h JSONB NOT NULL DEFAULT '{}'::jsonb, forecasts_12h JSONB NOT NULL DEFAULT '{}'::jsonb, aqi_input JSONB NOT NULL DEFAULT '{}'::jsonb