wallos/migrations/000011.php
Miguel Ribeiro aef2d134c2
feat: allow sorting payment methods (#217)
feat: don't allow to change currency code if in use
2024-03-10 12:09:14 +01:00

14 lines
580 B
PHP

<?php
// This migration adds a "order" column to the payment_methods table so that they can be sorted and initializes all values to their id.
/** @noinspection PhpUndefinedVariableInspection */
$columnQuery = $db->query("SELECT * FROM pragma_table_info('payment_methods') WHERE name='order'");
$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;
if ($columnRequired) {
$db->exec('ALTER TABLE payment_methods ADD COLUMN `order` INTEGER DEFAULT 0');
$db->exec('UPDATE payment_methods SET `order` = id');
}
?>