Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
Check for column existence in migration Allow migrations from bare installations
Matt Bannonf7b0116247b8
diff --git a/db/migrate.php b/db/migrate.phpindex 7e80351..b8eeea5 100644--- a/db/migrate.php+++ b/db/migrate.php@@ -1,6 +1,6 @@<?php/** @var \SQLite3 $db */-require_once 'includes/connect_endpoint_crontabs.php';+require_once 'includes/connect.php';$completedMigrations = [];diff --git a/migrations/000002.php b/migrations/000002.phpindex 720ae04..af478cf 100644--- a/migrations/000002.php+++ b/migrations/000002.php@@ -3,5 +3,10 @@// It allows the user to disable payment methods without deleting them./** @noinspection PhpUndefinedVariableInspection */-$db->exec('ALTER TABLE payment_methods ADD COLUMN enabled BOOLEAN DEFAULT 1');-$db->exec('UPDATE payment_methods SET enabled = 1');+$columnQuery = $db->query("SELECT * FROM pragma_table_info('payment_methods') where name='enabled'");+$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;++if ($columnRequired) {+ $db->exec('ALTER TABLE payment_methods ADD COLUMN enabled BOOLEAN DEFAULT 1');+ $db->exec('UPDATE payment_methods SET enabled = 1');+}