From: Alexander Ebert Date: Fri, 8 Dec 2017 13:17:08 +0000 (+0100) Subject: Added SQL update script for beta 4 X-Git-Tag: 3.1.0_Beta_4~12 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1d56abc146444b48a67c01f33362685ffe45adc0;p=GitHub%2FWoltLab%2FWCF.git Added SQL update script for beta 4 --- diff --git a/com.woltlab.wcf/update_3.1.0_beta_3.sql b/com.woltlab.wcf/update_3.1.0_beta_3.sql deleted file mode 100644 index 196658f6c1..0000000000 --- a/com.woltlab.wcf/update_3.1.0_beta_3.sql +++ /dev/null @@ -1,14 +0,0 @@ -ALTER TABLE wcf1_comment_response ADD COLUMN enableHtml TINYINT(1) NOT NULL DEFAULT 0; - -ALTER TABLE wcf1_style ADD COLUMN image2x VARCHAR(255) NOT NULL DEFAULT ''; - -DROP TABLE IF EXISTS wcf1_registry; -CREATE TABLE wcf1_registry ( - packageID INT(10) NOT NULL, - field VARCHAR(191) NOT NULL, - fieldValue MEDIUMTEXT, - - UNIQUE KEY uniqueField (packageID, field) -); - -ALTER TABLE wcf1_registry ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; diff --git a/com.woltlab.wcf/update_3.1.0_beta_4.sql b/com.woltlab.wcf/update_3.1.0_beta_4.sql new file mode 100644 index 0000000000..aa2ff37d3e --- /dev/null +++ b/com.woltlab.wcf/update_3.1.0_beta_4.sql @@ -0,0 +1 @@ +ALTER TABLE wcf1_style ADD coverPhotoExtension VARCHAR(4) NOT NULL DEFAULT ''; diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.1.0_beta_4_addColumn.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.1.0_beta_4_addColumn.php new file mode 100644 index 0000000000..e0476e16da --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.1.0_beta_4_addColumn.php @@ -0,0 +1,48 @@ + + * @package WoltLabSuite\Core + */ +$data = <<getVar('__wcfUpdateAddColumns'); +if ($rebuildData === null) { + $rebuildData = [ + 'i' => 0, + 'max' => count($lines) + ]; +} + +// MySQL adds a column by creating a new table in the +// background and copying over all the data afterwards. +// +// Using a single `ALTER TABLE` to add multiple columns +// results in the same runtime, because copying the table +// is what actually takes ages. +$statement = WCF::getDB()->prepareStatement(str_replace('wcf1_', 'wcf'.WCF_N.'_', $lines[$rebuildData['i']])); +$statement->execute(); + +$rebuildData['i']++; + +if ($rebuildData['i'] === $rebuildData['max']) { + WCF::getSession()->unregister('__wcfUpdateAddColumns'); +} +else { + WCF::getSession()->register('__wcfUpdateAddColumns', $rebuildData); + + // call this script again + throw new SplitNodeException(); +}