Files
Wallos/migrations/000016.php
Miguel Ribeiro 0fef9597ef fix: null array on empty subscription list
fix: don't use mbstring
feat: sort graphs on the statistics page by usage
feat: lifetime subscriptions
feat: allow multiple filters on the settings page
feat: filter by notification status
fix: migrations using double quotes
feat: rework icons
fix: open 3 dot menu abone for the subscriptions at the bottom
fix: ntfy notifications with strange chars
2026-05-17 00:54:14 +02:00

63 lines
2.0 KiB
PHP

<?php
/*
* This migration adds tables to store the date about the new notification methods (telegram, webhooks and gotify)
* Existing values on the notifications table will be split and migrated to the new tables.
*/
$db->exec("CREATE TABLE IF NOT EXISTS telegram_notifications (
enabled BOOLEAN DEFAULT 0,
bot_token TEXT DEFAULT '',
chat_id TEXT DEFAULT ''
)");
$db->exec("CREATE TABLE IF NOT EXISTS webhook_notifications (
enabled BOOLEAN DEFAULT 0,
headers TEXT DEFAULT '',
url TEXT DEFAULT '',
request_method TEXT DEFAULT 'POST',
payload TEXT DEFAULT '',
iterator TEXT DEFAULT ''
)");
$db->exec("CREATE TABLE IF NOT EXISTS gotify_notifications (
enabled BOOLEAN DEFAULT 0,
url TEXT DEFAULT '',
token TEXT DEFAULT ''
)");
$db->exec("CREATE TABLE IF NOT EXISTS email_notifications (
enabled BOOLEAN DEFAULT 0,
smtp_address TEXT DEFAULT '',
smtp_port INTEGER DEFAULT 587,
smtp_username TEXT DEFAULT '',
smtp_password TEXT DEFAULT '',
from_email TEXT DEFAULT '',
encryption TEXT DEFAULT 'tls'
)");
$db->exec('CREATE TABLE IF NOT EXISTS notification_settings (
days INTEGER DEFAULT 0
)');
// Check if old email notifications table has data and migrate it
$result = $db->query('SELECT COUNT(*) as count FROM notifications');
$row = $result->fetchArray(SQLITE3_ASSOC);
if ($row['count'] > 0) {
// Copy data from notifications to email_notifications
$db->exec('INSERT INTO email_notifications (enabled, smtp_address, smtp_port, smtp_username, smtp_password, from_email, encryption)
SELECT enabled, smtp_address, smtp_port, smtp_username, smtp_password, from_email, encryption FROM notifications');
// Copy data from notifications to notification_settings
$db->exec('INSERT INTO notification_settings (days)
SELECT days FROM notifications');
if ($db->changes() > 0) {
$db->exec('DROP TABLE IF EXISTS notifications');
}
} else {
$db->exec('DROP TABLE IF EXISTS notifications');
}
?>