getDB(); switch ($STEP) { case 1: echo '

the table websitesettings will be altered

'; echo '

the table menuitems will be altered

'; echo '

the table menublocks will be altered

'; echo '

the table groupmembers will be altered

'; echo '

the table groupsettings will be altered

'; echo '

the table grouptextsettings will be altered

'; echo '

the table groupbinsettings will be altered

'; echo 'Upgrade'; break; case 2: $db->isTransactionSupported() and $db->startTransaction(); foreach([ 'websitesettings', 'menuitems', 'menublocks', 'groupmembers', 'groupsettings', 'grouptextsettings', 'groupbinsettings', ] as $tbl) { foreach($db->table($tbl)->getFKeyList() as $fkey) $db->table($tbl)->removeFKey($fkey); } foreach([ 'menuitems', ] as $tbl) { foreach($db->table($tbl)->getIndexList() as $idx) $db->table($tbl)->removeIndex($idx); } if (!($db->getDialect() instanceof \Mammut\DB\Sql\Dialect\SqlServer)) $db->table('websites')->alterColumn('id', new ColumnInfo('id', Types::TYPE_SHORT, -1, [ColumnInfo::P_AUTONUM, ColumnInfo::P_UNSIGNED])); else $db->table('websites')->alterColumn('id', new ColumnInfo('id', Types::TYPE_SHORT, -1, [ColumnInfo::P_UNSIGNED])); $db->table('websitesettings')->alterColumn('site_id', new ColumnInfo('site_id', Types::TYPE_SHORT, -1, [ColumnInfo::P_ALLOW_NULL, ColumnInfo::P_UNSIGNED])); $db->table('websitesettings')->update(['site_id' => NULL], ['site_id' => 0]); $db->table('websitesettings')->addFKey('FK_site_id', ['site_id'], 'websites', ['id'], 'CASCADE', 'CASCADE'); $db->table('menuitems')->addFKey('FK_menu_id', ['menu_id'], 'menus', ['id'], 'CASCADE', 'CASCADE'); $db->table('menublocks')->alterColumn('menu_id', new ColumnInfo('menu_id', Types::TYPE_INT, -1, [ColumnInfo::P_ALLOW_NULL, ColumnInfo::P_UNSIGNED])); $db->table('menublocks')->addFKey('FK_menublocks_menu_id', ['menu_id'], 'menus', ['id'], 'NULL', 'CASCADE'); $db->table('groupmembers')->addFKey('FK_groupmembers_group_id', ['group_id'], 'groups', ['id'], 'CASCADE', 'CASCADE'); // $db->table('groupmembers')->addFKey('FK_groupmembers_account_id', ['account_id'], 'accounts', ['id'], 'CASCADE', 'CASCADE'); $db->table('groupsettings')->addFKey('FK_groupsettings_id', ['id'], 'groups', ['id'], 'CASCADE', 'CASCADE'); $db->table('grouptextsettings')->addFKey('FK_grouptextsettings_id', ['id'], 'groups', ['id'], 'CASCADE', 'CASCADE'); $db->table('groupbinsettings')->addFKey('FK_groupbinsettings_id', ['id'], 'groups', ['id'], 'CASCADE', 'CASCADE'); $db->table('installinfo')->delete(array('type' =>'system', 'key' => 'mcms')); $db->table('installinfo')->delete(array('type' =>'system', 'key' => 'mcmsdb')); $db->table('installinfo')->insert(array('type' =>'system', 'key' => 'mcms', 'version' => MCMS, 'attrib' => 0)); $db->table('installinfo')->insert(array('type' =>'system', 'key' => 'mcmsdb', 'version' => $DBV, 'attrib' => 0)); $db->isTransactionSupported() and $db->commit(); echo '

upgrade finished, remove the install folder and return to your system

'; echo 'Back to main page'; break; }