From 1379c934399d429fca1099e720961674834de9cf Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 31 Oct 2025 07:00:11 +0100 Subject: [PATCH] Create 47.php --- system/migrations/47.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 system/migrations/47.php diff --git a/system/migrations/47.php b/system/migrations/47.php new file mode 100644 index 00000000..ea98d6f2 --- /dev/null +++ b/system/migrations/47.php @@ -0,0 +1,27 @@ +query("ALTER TABLE `myaac_account_actions` DROP KEY `account_id`;"); + $db->query("ALTER TABLE `myaac_account_actions` ADD COLUMN `id` INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`);"); + + $db->modifyColumn(TABLE_PREFIX . 'account_actions', 'ip', "VARCHAR(45) NOT NULL DEFAULT ''"); + $db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET_NTOA(`ip`) WHERE `ip` != '0';"); + $db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET6_NTOA(`ipv6`) WHERE `ip` = '0';"); + $db->dropColumn(TABLE_PREFIX . 'account_actions', 'ipv6'); +}; + +$down = function () use ($db) { + $db->query("ALTER TABLE `" . TABLE_PREFIX . "account_actions` DROP `id`;"); + $db->query("ALTER TABLE `" . TABLE_PREFIX . "account_actions` ADD KEY (`account_id`);"); + + $db->addColumn(TABLE_PREFIX . 'account_actions', 'ipv6', "BINARY(16) NOT NULL DEFAULT 0x00000000000000000000000000000000 AFTER ip"); + $db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ipv6` = INET6_ATON(ip) WHERE NOT IS_IPV4(`ip`);"); + $db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET_ATON(`ip`) WHERE IS_IPV4(`ip`);"); + $db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = 0 WHERE `ipv6` != 0x00000000000000000000000000000000;"); + $db->modifyColumn(TABLE_PREFIX . 'account_actions', 'ip', "INT(11) UNSIGNED NOT NULL DEFAULT 0;"); +};