diff options
Diffstat (limited to 'migrations/20240101000400_create_weather_api_data.sql')
| -rw-r--r-- | migrations/20240101000400_create_weather_api_data.sql | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/migrations/20240101000400_create_weather_api_data.sql b/migrations/20240101000400_create_weather_api_data.sql new file mode 100644 index 0000000..16fdf35 --- /dev/null +++ b/migrations/20240101000400_create_weather_api_data.sql @@ -0,0 +1,15 @@ +-- Migration: Create weather_api_data table +CREATE TABLE IF NOT EXISTS weather_api_data ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL, + location_id INTEGER NOT NULL, + api_type TEXT NOT NULL DEFAULT 'openweathermap', + data TEXT NOT NULL, -- JSON data from the API + fetched_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(location_id) REFERENCES locations(id) ON DELETE CASCADE +); +CREATE INDEX IF NOT EXISTS idx_weather_api_data_user_id ON weather_api_data(user_id); +CREATE INDEX IF NOT EXISTS idx_weather_api_data_location_id ON weather_api_data(location_id); +CREATE INDEX IF NOT EXISTS idx_weather_api_data_fetched_at ON weather_api_data(fetched_at); +CREATE INDEX IF NOT EXISTS idx_weather_api_data_api_type ON weather_api_data(api_type);
\ No newline at end of file |
