Skip to content

Instantly share code, notes, and snippets.

@Koala
Forked from tbaddade/_readme.markdown
Last active November 10, 2018 12:13
Show Gist options
  • Save Koala/fa1eccb77370195aa3d2017443c00fda to your computer and use it in GitHub Desktop.
Save Koala/fa1eccb77370195aa3d2017443c00fda to your computer and use it in GitHub Desktop.
REDAXO Update 3.2 auf 4.5.1

1/ REDAXO 4.5.1 installieren

2/ via phpMyAdmin

  • alle Tabellen löschen
  • SQL Dump importieren
  • Datei "update_3_2_to_4_5_1.sql" ausführen

3/ Kollation auf "utf8_general_ci"

Sollen alle Tabellenspalten die Kollation "utf8_general_ci" erhalten, Datei "change_columns_collation_to_utf8.php" innerhalb von REDAXO ausführen.

Hinweis:

Für die Redaxo eigenen Tabellen ist die Anpassung bereits in der SQL-Datei mit vorhanden. Um nicht die Datei "change_columns_collation_to_utf8.php" ausführen zu müssen, kann die Änderung der übrigen Tabellen auch händisch in phpMyAdmin ausgeführt werden. Dazu ist diese Zeile zu verwenden ("DEINE-TABELLE" ist durch die zu ändernde Tabelle zu ersetzen):

ALTER TABLE `rex_DEINE-TABELLE` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

4/ AddOns re-installieren

  • ImageManager
  • Metainfo

5/ Templates anpassen

  • header('Content-Type: text/html; charset=utf-8');
  • <meta http-equiv="content-type" content="text/html; charset=utf-8">
<?php
/*
* boolean
* true > convert all tables
* false > convert all tables prefixed by $REX['TABLE_PREFIX'] (rex_)
*/
$convert_all_tables_in_database = true;
/*
* boolean
*/
$check_before_update = false;
$sql = new rex_sql();
$tables = $sql->getArray('SHOW TABLES');
if ($sql->getRows() >= 1) {
foreach ($tables as $table) {
$table_name = $table['Tables_in_' . $REX['DB']['1']['NAME']];
$convert = false;
if ($convert_all_tables_in_database || (substr($table_name, 0, 4) == $REX['TABLE_PREFIX'])) {
$convert = true;
}
if ($convert) {
if ($check_before_update) {
echo '
<div style="margin: 5px; padding: 10px; background-color: #D2EFD9; color: #107C2C;">
->setQuery(ALTER TABLE `' . $table_name . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci);
</div>';
} else {
$update = new rex_sql();
$update->debugsql = true;
$update->setQuery('ALTER TABLE `' . $table_name . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
}
}
}
}
?>
-- Update von Redaxo 3.2 zu Redaxo 4.5.1
ALTER TABLE `rex_action` ADD `preview` TEXT, ADD `presave` TEXT, ADD `postsave` TEXT, ADD `previewmode` TINYINT NULL, ADD `presavemode` TINYINT NULL, ADD `postsavemode` TINYINT NULL;
-- weise die Aktionen den neuen Spalten richtig zu
UPDATE `rex_action` SET `presave` = `action` WHERE `prepost` = '0';
UPDATE `rex_action` SET `postsave` = `action` WHERE `prepost` = '1';
UPDATE `rex_action` SET `presavemode` = `sadd` + 2 * `sedit` + 4 * `sdelete` WHERE `prepost` = '0';
UPDATE `rex_action` SET `postsavemode` = `sadd` + 2 * `sedit` + 4 * `sdelete` WHERE `prepost` = '1';
ALTER TABLE `rex_action` DROP `action`, DROP `prepost`, DROP `sadd`, DROP `sedit`, DROP `sdelete`;
ALTER TABLE `rex_action` ADD `createuser` VARCHAR(255) NOT NULL, ADD `createdate` INT(11) NOT NULL, ADD `updateuser` VARCHAR(255) NOT NULL, ADD `updatedate` INT(11) NOT NULL;
ALTER TABLE `rex_action` ADD `revision` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `rex_article` DROP `cattype`;
ALTER TABLE `rex_article` DROP `alias`;
ALTER TABLE `rex_article` DROP `fe_user`;
ALTER TABLE `rex_article` DROP `fe_group`;
ALTER TABLE `rex_article` DROP `fe_ext`;
ALTER TABLE `rex_article` ADD `revision` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `rex_article` ADD `art_online_from` TEXT NULL;
ALTER TABLE `rex_article` ADD `art_online_to` TEXT NULL;
ALTER TABLE `rex_article` ADD `art_description` TEXT NULL;
ALTER TABLE `rex_article` ADD `art_keywords` TEXT NULL;
ALTER TABLE `rex_article` ADD `art_file` VARCHAR(255) NULL;
ALTER TABLE `rex_article` ADD `art_teaser` VARCHAR(255) NULL;
ALTER TABLE `rex_article` ADD `art_type_id` VARCHAR(255) NULL;
-- hole Inhalte in neue Spalten vor dem Löschen der bisherigen Spalten
UPDATE `rex_article` SET `art_description` = `description`;
UPDATE `rex_article` SET `art_keywords` = `keywords`;
UPDATE `rex_article` SET `art_file` = `file`;
UPDATE `rex_article` SET `art_teaser` = '|true|' WHERE `teaser` = '1';
UPDATE `rex_article` SET `art_type_id` = 'Standard' WHERE `type_id` = '1';
UPDATE `rex_article` SET `art_online_from` = `online_from`;
UPDATE `rex_article` SET `art_online_to` = `online_to`;
ALTER TABLE `rex_article` DROP `online_from`;
ALTER TABLE `rex_article` DROP `online_to`;
ALTER TABLE `rex_article` DROP `type_id`;
ALTER TABLE `rex_article` DROP `teaser`;
ALTER TABLE `rex_article` DROP `description`;
ALTER TABLE `rex_article` DROP `keywords`;
ALTER TABLE `rex_article` DROP `file`;
ALTER TABLE `rex_article` CHANGE `attribute` `attributes` TEXT NOT NULL;
ALTER TABLE `rex_article_slice` CHANGE `value1` `value1` text NULL, CHANGE `value2` `value2` text NULL, CHANGE `value3` `value3` text NULL, CHANGE `value4` `value4` text NULL, CHANGE `value5` `value5` text NULL, CHANGE `value6` `value6` text NULL, CHANGE `value7` `value7` text NULL, CHANGE `value8` `value8` text NULL, CHANGE `value9` `value9` text NULL, CHANGE `value10` `value10` text NULL, CHANGE `value11` `value11` text NULL, CHANGE `value12` `value12` text NULL, CHANGE `value13` `value13` text NULL, CHANGE `value14` `value14` text NULL, CHANGE `value15` `value15` text NULL, CHANGE `value16` `value16` text NULL, CHANGE `value17` `value17` text NULL, CHANGE `value18` `value18` text NULL, CHANGE `value19` `value19` text NULL, CHANGE `value20` `value20` text NULL, CHANGE `file1` `file1` varchar(255) NULL, CHANGE `file2` `file2` varchar(255) NULL, CHANGE `file3` `file3` varchar(255) NULL, CHANGE `file4` `file4` varchar(255) NULL, CHANGE `file5` `file5` varchar(255) NULL, CHANGE `file6` `file6` varchar(255) NULL, CHANGE `file7` `file7` varchar(255) NULL, CHANGE `file8` `file8` varchar(255) NULL, CHANGE `file9` `file9` varchar(255) NULL, CHANGE `file10` `file10` varchar(255) NULL, CHANGE `filelist1` `filelist1` text NULL, CHANGE `filelist2` `filelist2` text NULL, CHANGE `filelist3` `filelist3` text NULL, CHANGE `filelist4` `filelist4` text NULL, CHANGE `filelist5` `filelist5` text NULL, CHANGE `filelist6` `filelist6` text NULL, CHANGE `filelist7` `filelist7` text NULL, CHANGE `filelist8` `filelist8` text NULL, CHANGE `filelist9` `filelist9` text NULL, CHANGE `filelist10` `filelist10` text NULL, CHANGE `link1` `link1` varchar(10) NULL, CHANGE `link2` `link2` varchar(10) NULL, CHANGE `link3` `link3` varchar(10) NULL, CHANGE `link4` `link4` varchar(10) NULL, CHANGE `link5` `link5` varchar(10) NULL, CHANGE `link6` `link6` varchar(10) NULL, CHANGE `link7` `link7` varchar(10) NULL, CHANGE `link8` `link8` varchar(10) NULL, CHANGE `link9` `link9` varchar(10) NULL, CHANGE `link10` `link10` varchar(10) NULL, CHANGE `linklist1` `linklist1` text NULL, CHANGE `linklist2` `linklist2` text NULL, CHANGE `linklist3` `linklist3` text NULL, CHANGE `linklist4` `linklist4` text NULL, CHANGE `linklist5` `linklist5` text NULL, CHANGE `linklist6` `linklist6` text NULL, CHANGE `linklist7` `linklist7` text NULL, CHANGE `linklist8` `linklist8` text NULL, CHANGE `linklist9` `linklist9` text NULL, CHANGE `linklist10` `linklist10` text NULL, CHANGE `php` `php` text NULL, CHANGE `html` `html` text NULL;
ALTER TABLE `rex_article_slice` CHANGE `clang` `clang` INT(11) NOT NULL, CHANGE `ctype` `ctype` INT(11) NOT NULL, CHANGE `re_article_slice_id` `re_article_slice_id` INT(11) NOT NULL, CHANGE `article_id` `article_id` INT(11) NOT NULL, CHANGE `createdate` `createdate` INT(11) NOT NULL, CHANGE `updatedate` `updatedate` INT(11) NOT NULL;
ALTER TABLE `rex_article_slice` ADD `next_article_slice_id` int(11);
UPDATE `rex_article_slice` SET `ctype`=`ctype`+1;
ALTER TABLE `rex_article_slice` ADD `revision` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `rex_clang` ADD `revision` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `rex_file` ADD `attributes` TEXT NULL AFTER `category_id`;
ALTER TABLE `rex_file` ADD `revision` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `rex_file` ADD `med_description` TEXT NULL;
ALTER TABLE `rex_file` ADD `med_copyright` TEXT NULL;
-- hole Inhalte in neue Spalten vor dem Löschen der bisherigen Spalten
UPDATE `rex_file` SET `med_description` = `description`;
UPDATE `rex_file` SET `med_copyright` = `copyright`;
ALTER TABLE `rex_file` DROP `copyright`;
ALTER TABLE `rex_file` DROP `description`;
ALTER TABLE `rex_file` CHANGE `filetype` `filetype` VARCHAR(255) NULL, CHANGE `filename` `filename` VARCHAR(255) NULL, CHANGE `originalname` `originalname` VARCHAR(255) NULL, CHANGE `filesize` `filesize` VARCHAR(255) NULL, CHANGE `title` `title` VARCHAR(255) NULL, CHANGE `width` `width` INT(11) NULL, CHANGE `height` `height` INT(11) NULL;
ALTER TABLE `rex_file_category` DROP `hide`;
ALTER TABLE `rex_file_category` ADD `attributes` TEXT NULL;
ALTER TABLE `rex_file_category` ADD `revision` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `rex_modultyp` DROP `bausgabe`;
ALTER TABLE `rex_modultyp` DROP `func`;
ALTER TABLE `rex_modultyp` DROP `php_enable`;
ALTER TABLE `rex_modultyp` DROP `html_enable`;
ALTER TABLE `rex_modultyp` DROP `perm_category`;
ALTER TABLE `rex_modultyp` DROP `label`;
ALTER TABLE `rex_modultyp` ADD `attributes` TEXT NULL;
ALTER TABLE `rex_modultyp` ADD `revision` INT( 11 ) NOT NULL DEFAULT '0';
RENAME TABLE `rex_modultyp` TO `rex_module`;
ALTER TABLE `rex_module_action` ADD `revision` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `rex_template` DROP `bcontent`;
ALTER TABLE `rex_template` DROP `date`;
ALTER TABLE `rex_template` ADD `attributes` TEXT NULL;
ALTER TABLE `rex_template` ADD `revision` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `rex_template` CHANGE `label` `label` VARCHAR(255) NULL, CHANGE `name` `name` VARCHAR(255) NULL, CHANGE `content` `content` TEXT NULL, CHANGE `active` `active` TINYINT(1) NULL;
-- Da im normalen Redaxoexport keine User-Tabelle dabei ist, ist der Bereich kommentiert
ALTER TABLE `rex_user` ADD `cookiekey` varchar(255);
ALTER TABLE `rex_user` ADD `revision` INT(11) NOT NULL DEFAULT '0';
UPDATE `rex_user` SET `status`=1;
DROP TABLE `rex_article_type`;
-- ###################################################
-- INDEXe
-- Da im normalen Redaxoexport keine User-Tabelle dabei ist, ist der entsprechende Bereich kommentiert
-- ###################################################
ALTER TABLE rex_article ADD INDEX `id` (`id`), ADD INDEX `clang` (`clang`), ADD UNIQUE INDEX `find_articles` (`id`, `clang`), ADD INDEX `re_id` (`re_id`);
ALTER TABLE rex_article_slice ADD INDEX `id` (`id`), ADD INDEX `clang` (`clang`), ADD INDEX `re_article_slice_id` (`re_article_slice_id`), ADD INDEX `article_id` (`article_id`), ADD INDEX `find_slices` (`clang`, `article_id`);
ALTER TABLE rex_file ADD INDEX `re_file_id` (`re_file_id`), ADD INDEX `category_id` (`category_id`);
ALTER TABLE rex_file_category DROP PRIMARY KEY, ADD PRIMARY KEY (`id`), ADD INDEX `re_id` (`re_id`);
ALTER TABLE rex_module DROP PRIMARY KEY, ADD PRIMARY KEY (`id`), ADD INDEX `category_id` (`category_id`);
ALTER TABLE rex_user ADD UNIQUE INDEX `login` (`login`(50));
ALTER TABLE `rex_action` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_article` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_article_slice` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_clang` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_file` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_file_category` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_module` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_module_action` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_template` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rex_user` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment