execute( 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'ws_customhtml_group_lang` ( `id_ws_customhtml_group` INT(11) NOT NULL, `id_lang` INT(11) NOT NULL, `title` VARCHAR(256) NOT NULL DEFAULT \'\', PRIMARY KEY (`id_ws_customhtml_group`, `id_lang`) );' ); } function migrateGroupTitlesToLangTable(): bool { $groupColumns = Db::getInstance()->executeS( 'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_group` LIKE \'title\'' ); if (empty($groupColumns)) { // Already migrated in a previous run of this upgrade. return true; } $groups = Db::getInstance()->executeS( 'SELECT `id_ws_customhtml_group`, `title` FROM `' . _DB_PREFIX_ . 'ws_customhtml_group`' ); $languages = Language::getLanguages(false); foreach ($groups as $group) { foreach ($languages as $language) { $existing = Db::getInstance()->executeS( 'SELECT 1 FROM `' . _DB_PREFIX_ . 'ws_customhtml_group_lang` WHERE `id_ws_customhtml_group` = ' . (int) $group['id_ws_customhtml_group'] . ' AND `id_lang` = ' . (int) $language['id_lang'] ); if (!empty($existing)) { continue; } $result = Db::getInstance()->insert('ws_customhtml_group_lang', [ 'id_ws_customhtml_group' => (int) $group['id_ws_customhtml_group'], 'id_lang' => (int) $language['id_lang'], 'title' => pSQL($group['title']), ]); if (!$result) { return false; } } } return true; } function dropGroupTitleColumn(): bool { $groupColumns = Db::getInstance()->executeS( 'SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'ws_customhtml_group` LIKE \'title\'' ); if (empty($groupColumns)) { return true; } return Db::getInstance()->execute( 'ALTER TABLE `' . _DB_PREFIX_ . 'ws_customhtml_group` DROP COLUMN `title`' ); }