Check for column existence in migration
Allow migrations from bare installations
This commit is contained in:
parent
ca7e908af1
commit
f7b0116247
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/** @var \SQLite3 $db */
|
/** @var \SQLite3 $db */
|
||||||
require_once 'includes/connect_endpoint_crontabs.php';
|
require_once 'includes/connect.php';
|
||||||
|
|
||||||
$completedMigrations = [];
|
$completedMigrations = [];
|
||||||
|
|
||||||
|
|||||||
@ -3,5 +3,10 @@
|
|||||||
// It allows the user to disable payment methods without deleting them.
|
// It allows the user to disable payment methods without deleting them.
|
||||||
|
|
||||||
/** @noinspection PhpUndefinedVariableInspection */
|
/** @noinspection PhpUndefinedVariableInspection */
|
||||||
$db->exec('ALTER TABLE payment_methods ADD COLUMN enabled BOOLEAN DEFAULT 1');
|
$columnQuery = $db->query("SELECT * FROM pragma_table_info('payment_methods') where name='enabled'");
|
||||||
$db->exec('UPDATE payment_methods SET enabled = 1');
|
$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');
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user