feat: switch from MySQL to SQLite for zero-dependency deployment
- Rewrite db.php to use SQLite via PDO (no external DB server needed) - Rewrite schema.sql for SQLite (AUTOINCREMENT, CHECK constraints, triggers for updated_at, ON CONFLICT instead of ON DUPLICATE KEY) - Fix config.php upsert to use ON CONFLICT syntax - Fix index.php: tag filter via json_each, vote upsert via ON CONFLICT, and fix protocol create route (was returning 405 for POST /api/protocols) - Fix yaml.php seed import: replace invalid false callbacks with fn() => null, fix yaml_parse pos argument (-1 -> 0) - Update Dockerfile: drop pdo_mysql/mysqli (pdo_sqlite is built in) - Update CloudronManifest.json: remove mysql addon, bump to v0.3.0 - Update README for SQLite deployment
This commit is contained in:
Executable → Regular
+3
-3
@@ -4,19 +4,19 @@
|
||||
*/
|
||||
|
||||
function config_get(string $key, $default = null) {
|
||||
$row = db_one("SELECT value FROM config WHERE `key` = ?", [$key]);
|
||||
$row = db_one("SELECT value FROM config WHERE key = ?", [$key]);
|
||||
return $row ? $row['value'] : $default;
|
||||
}
|
||||
|
||||
function config_set(string $key, string $value): void {
|
||||
db_query(
|
||||
"INSERT INTO config (`key`, `value`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`)",
|
||||
"INSERT INTO config (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
|
||||
[$key, $value]
|
||||
);
|
||||
}
|
||||
|
||||
function config_all(): array {
|
||||
$rows = db_all("SELECT `key`, `value` FROM config");
|
||||
$rows = db_all("SELECT key, value FROM config");
|
||||
$cfg = [];
|
||||
foreach ($rows as $row) {
|
||||
$cfg[$row['key']] = $row['value'];
|
||||
|
||||
Reference in New Issue
Block a user