blob: 16fdf3563261c028c7a56c62463266ab8a63a7e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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);
|