diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-14 19:34:59 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-14 19:34:59 +0300 |
| commit | 50ce8cb96b2b218751c2fc2a6b19372f51846acc (patch) | |
| tree | e2c634d2ce856062d527667d47815a05a53361c8 /migrations | |
| parent | 0ab2e5ba2b0631b28b5b1405559237b3913c878f (diff) | |
feat: rewrite in rust
Diffstat (limited to 'migrations')
4 files changed, 60 insertions, 0 deletions
diff --git a/migrations/20240101000000_create_users.sql b/migrations/20240101000000_create_users.sql new file mode 100644 index 0000000..8519916 --- /dev/null +++ b/migrations/20240101000000_create_users.sql @@ -0,0 +1,6 @@ +-- Migration: Create users table +CREATE TABLE IF NOT EXISTS users ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id TEXT NOT NULL UNIQUE, + role TEXT NOT NULL DEFAULT 'user' +);
\ No newline at end of file diff --git a/migrations/20240101000100_create_locations.sql b/migrations/20240101000100_create_locations.sql new file mode 100644 index 0000000..501fb10 --- /dev/null +++ b/migrations/20240101000100_create_locations.sql @@ -0,0 +1,9 @@ +-- Migration: Create locations table +CREATE TABLE IF NOT EXISTS locations ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + latitude REAL NOT NULL, + longitude REAL NOT NULL, + user_id INTEGER NOT NULL, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE NO ACTION +); +CREATE INDEX IF NOT EXISTS idx_locations_user_id ON locations(user_id);
\ No newline at end of file diff --git a/migrations/20240101000200_create_weather_thresholds.sql b/migrations/20240101000200_create_weather_thresholds.sql new file mode 100644 index 0000000..d6ebf0d --- /dev/null +++ b/migrations/20240101000200_create_weather_thresholds.sql @@ -0,0 +1,13 @@ +-- Migration: Create weather_thresholds table +CREATE TABLE IF NOT EXISTS weather_thresholds ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL, + condition_type TEXT NOT NULL, + threshold_value REAL NOT NULL, + operator TEXT NOT NULL, + enabled BOOLEAN NOT NULL DEFAULT 1, + description TEXT, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE +); +CREATE INDEX IF NOT EXISTS idx_weather_thresholds_user_id ON weather_thresholds(user_id); +CREATE INDEX IF NOT EXISTS idx_weather_thresholds_condition_type ON weather_thresholds(condition_type);
\ No newline at end of file diff --git a/migrations/20240101000300_create_user_notification_settings.sql b/migrations/20240101000300_create_user_notification_settings.sql new file mode 100644 index 0000000..13d45cd --- /dev/null +++ b/migrations/20240101000300_create_user_notification_settings.sql @@ -0,0 +1,32 @@ +-- Migration: Create user_ntfy_settings table +CREATE TABLE IF NOT EXISTS user_ntfy_settings ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL, + enabled BOOLEAN NOT NULL DEFAULT 0, + topic TEXT NOT NULL, + server_url TEXT NOT NULL, + priority INTEGER NOT NULL DEFAULT 5, + title_template TEXT, + message_template TEXT, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE +); +CREATE UNIQUE INDEX IF NOT EXISTS idx_user_ntfy_settings_user_id ON user_ntfy_settings(user_id); + +-- Migration: Create user_smtp_settings table +CREATE TABLE IF NOT EXISTS user_smtp_settings ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL, + enabled BOOLEAN NOT NULL DEFAULT 0, + email TEXT NOT NULL, + smtp_server TEXT NOT NULL, + smtp_port INTEGER NOT NULL, + username TEXT, + password TEXT, + use_tls BOOLEAN NOT NULL DEFAULT 1, + from_email TEXT, + from_name TEXT DEFAULT 'Silmätaivas Alerts', + subject_template TEXT, + body_template TEXT, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE +); +CREATE UNIQUE INDEX IF NOT EXISTS idx_user_smtp_settings_user_id ON user_smtp_settings(user_id);
\ No newline at end of file |
