Refactor migrations with $up & $down

This commit is contained in:
slawkens
2024-11-08 07:04:24 +01:00
parent c7cb00f8da
commit 8aff9f36fb
49 changed files with 842 additions and 370 deletions

View File

@@ -1,12 +1,16 @@
<?php
/**
* @var OTS_DB_MySQL $db
*/
// Increase size of ip in myaac_visitors table
// according to this answer: https://stackoverflow.com/questions/166132/maximum-length-of-the-textual-representation-of-an-ipv6-address
// the size of ipv6 can be maximal 45 chars
$up = function () use ($db) {
$db->exec('ALTER TABLE `' . TABLE_PREFIX . "visitors` MODIFY `ip` VARCHAR(45) NOT NULL;");
$db->modifyColumn(TABLE_PREFIX . 'visitors', 'ip', 'VARCHAR(15) NOT NULL');
};
$down = function () {
$down = function () use ($db) {
// nothing to be done, as we have just extended the size of a column
};