当前位置: 首页>>代码示例>>PHP>>正文


PHP Migration::upgrade方法代码示例

本文整理汇总了PHP中Migration::upgrade方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::upgrade方法的具体用法?PHP Migration::upgrade怎么用?PHP Migration::upgrade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Migration的用法示例。


在下文中一共展示了Migration::upgrade方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upgrade

 public static function upgrade()
 {
     // 2.2.2 Beta 1
     if (version_compare(self::$existing_version, '2.2.2 Beta 1', '<=')) {
         Symphony::Configuration()->set('version', '2.2.2 Beta 1', 'symphony');
         // Rename old variations of the query_caching configuration setting
         if (Symphony::Configuration()->get('disable_query_caching', 'database')) {
             $value = Symphony::Configuration()->get('disable_query_caching', 'database') == "no" ? "on" : "off";
             Symphony::Configuration()->set('query_caching', $value, 'database');
             Symphony::Configuration()->remove('disable_query_caching', 'database');
         }
         // Add Session GC collection as a configuration parameter
         Symphony::Configuration()->set('session_gc_divisor', '10', 'symphony');
         // Save the manifest changes
         Symphony::Configuration()->write();
     }
     // 2.2.2 Beta 2
     if (version_compare(self::$existing_version, '2.2.2 Beta 2', '<=')) {
         Symphony::Configuration()->set('version', '2.2.2 Beta 2', 'symphony');
         try {
             // Change Textareas to be MEDIUMTEXT columns
             $textarea_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_textarea`");
             foreach ($textarea_tables as $field) {
                 Symphony::Database()->query(sprintf("ALTER TABLE `tbl_entries_data_%d` CHANGE `value` `value` MEDIUMTEXT, CHANGE `value_formatted` `value_formatted` MEDIUMTEXT", $field));
                 Symphony::Database()->query(sprintf('OPTIMIZE TABLE `tbl_entries_data_%d`', $field));
             }
         } catch (Exception $ex) {
         }
         // Save the manifest changes
         Symphony::Configuration()->write();
     }
     // Update the version information
     return parent::upgrade();
 }
开发者ID:roshinebagha,项目名称:Symphony-Test,代码行数:34,代码来源:2.2.2.php

示例2: upgrade

    public static function upgrade()
    {
        if (version_compare(self::$existing_version, '2.3.4beta1', '<=')) {
            // Detect mod_rewrite #1808
            try {
                $htaccess = file_get_contents(DOCROOT . '/.htaccess');
                if ($htaccess !== false && !preg_match('/SetEnv HTTP_MOD_REWRITE No/', $htaccess)) {
                    $rewrite = '
<IfModule !mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE No
</IfModule>

<IfModule mod_rewrite.c>';
                    $htaccess = str_replace('<IfModule mod_rewrite.c>', $rewrite, $htaccess);
                    file_put_contents(DOCROOT . '/.htaccess', $htaccess);
                }
            } catch (Exception $ex) {
            }
            // Extend token field to enable more secure tokens
            try {
                Symphony::Database()->query('ALTER TABLE `tbl_forgotpass` CHANGE `token` `token` VARCHAR(16);');
            } catch (Exception $ex) {
            }
        }
        if (version_compare(self::$existing_version, '2.3.4beta2', '<=')) {
            // Extend session_id field for default Suhosin installs
            try {
                Symphony::Database()->query('ALTER TABLE `tbl_sessions` CHANGE `session` `session` VARCHAR(128);');
            } catch (Exception $ex) {
            }
        }
        // Update the version information
        return parent::upgrade();
    }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:34,代码来源:2.3.4.php

示例3: upgrade

 public static function upgrade()
 {
     // Add date field options
     try {
         Symphony::Database()->query('
                 ALTER TABLE `tbl_fields_date`
                 ADD `calendar` enum("yes","no") COLLATE utf8_unicode_ci NOT NULL DEFAULT "no",
                 ADD `time` enum("yes","no") COLLATE utf8_unicode_ci NOT NULL DEFAULT "yes";
             ');
     } catch (Exception $ex) {
     }
     // Add namespace field to the cache table. RE: #2162
     try {
         Symphony::Database()->query('
                 ALTER TABLE `tbl_cache` ADD `namespace` VARCHAR(255) COLLATE utf8_unicode_ci;
             ');
     } catch (Exception $ex) {
     }
     // Add UNIQUE key constraint to the `hash` RE: #2163
     try {
         Symphony::Database()->import('
                 ALTER TABLE `tbl_cache` DROP INDEX `hash`;
                 ALTER TABLE `tbl_cache` ADD UNIQUE INDEX `hash` (`hash`)
             ');
     } catch (Exception $ex) {
     }
     // Update the version information
     return parent::upgrade();
 }
开发者ID:roshinebagha,项目名称:Symphony-Test,代码行数:29,代码来源:2.6.0.php

示例4: upgrade

    public static function upgrade()
    {
        // 2.3.1dev
        if (version_compare(self::$existing_version, '2.3.1dev', '<=')) {
            // Remove unused setting from the Author field
            $author_table = 'tbl_fields_author';
            if (Symphony::Database()->tableContainsField($author_table, 'allow_author_change')) {
                Symphony::Database()->query("ALTER TABLE `{$author_table}` DROP `allow_author_change`;");
            }
            // Author Types [#1219]
            if (!Symphony::Database()->tableContainsField($author_table, 'author_types')) {
                Symphony::Database()->query("ALTER TABLE `{$author_table}` ADD `author_types` VARCHAR(255) DEFAULT NULL;");
            }
            // Entries Modification Date [#983]
            if (!Symphony::Database()->tableContainsField('tbl_entries', 'modification_date')) {
                Symphony::Database()->query("ALTER TABLE `tbl_entries` ADD `modification_date` DATETIME NOT NULL;");
                Symphony::Database()->query("ALTER TABLE `tbl_entries` ADD KEY `modification_date` (`modification_date`)");
                Symphony::Database()->query("UPDATE `tbl_entries` SET modification_date = creation_date;");
            }
            if (!Symphony::Database()->tableContainsField('tbl_entries', 'modification_date_gmt')) {
                Symphony::Database()->query("ALTER TABLE `tbl_entries` ADD `modification_date_gmt` DATETIME NOT NULL;");
                Symphony::Database()->query("ALTER TABLE `tbl_entries` ADD KEY `modification_date_gmt` (`modification_date_gmt`)");
                Symphony::Database()->query("UPDATE `tbl_entries` SET modification_date_gmt = creation_date_gmt;");
            }
            // Cleanup #977, remove `entry_order` & `entry_order_direction` from `tbl_sections`
            if (Symphony::Database()->tableContainsField('tbl_sections', 'entry_order')) {
                Symphony::Database()->query("ALTER TABLE `tbl_sections` DROP `entry_order`;");
            }
            if (Symphony::Database()->tableContainsField('tbl_sections', 'entry_order_direction')) {
                Symphony::Database()->query("ALTER TABLE `tbl_sections` DROP `entry_order_direction`;");
            }
        }
        if (version_compare(self::$existing_version, '2.3.1RC1', '<=')) {
            // Add Security Rules from 2.2 to .htaccess
            try {
                $htaccess = file_get_contents(DOCROOT . '/.htaccess');
                if ($htaccess !== false && preg_match('/### SECURITY - Protect crucial files/', $htaccess)) {
                    $security = '
            ### SECURITY - Protect crucial files
            RewriteRule ^manifest/(.*)$ - [F]
            RewriteRule ^workspace/(pages|utilities)/(.*)\\.xsl$ - [F]
            RewriteRule ^(.*)\\.sql$ - [F]
            RewriteRule (^|/)\\. - [F]

            ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"';
                    $htaccess = str_replace('### SECURITY - Protect crucial files.*### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"', $security, $htaccess);
                    file_put_contents(DOCROOT . '/.htaccess', $htaccess);
                }
            } catch (Exception $ex) {
            }
            // Increase length of password field to accomodate longer hashes
            Symphony::Database()->query("ALTER TABLE `tbl_authors` CHANGE `password` `password` VARCHAR( 150 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
        }
        // Update the version information
        return parent::upgrade();
    }
开发者ID:roshinebagha,项目名称:Symphony-Test,代码行数:56,代码来源:2.3.1.php

示例5: upgrade

 public static function upgrade()
 {
     // Add the upload blacklist (see c763e6a)
     $blacklist = Symphony::Configuration()->get('upload_blacklist', 'admin');
     if (empty($blacklist)) {
         Symphony::Configuration()->set('upload_blacklist', '/\\.(?:php[34567s]?|phtml)$/i', 'admin');
     }
     // Update the version information
     return parent::upgrade();
 }
开发者ID:symphonycms,项目名称:symphony-2,代码行数:10,代码来源:2.6.6.php

示例6: upgrade

    static function upgrade()
    {
        // [#702] Update to include Admin Path configuration
        if (version_compare(self::$existing_version, '2.4beta2', '<=')) {
            // Add missing config value for index view string length
            Symphony::Configuration()->set('cell_truncation_length', '75', 'symphony');
            // Add admin-path to configuration
            Symphony::Configuration()->set('admin-path', 'symphony', 'symphony');
        }
        // [#1626] Update all tables to be UTF-8 encoding/collation
        // @link https://gist.github.com/michael-e/5789168
        $tables = Symphony::Database()->fetch("SHOW TABLES");
        if (is_array($tables) && !empty($tables)) {
            foreach ($tables as $table) {
                $table = current($table);
                // If it's not a Symphony table, ignore it
                if (!preg_match('/^' . Symphony::Database()->getPrefix() . '/', $table)) {
                    continue;
                }
                Symphony::Database()->query(sprintf("ALTER TABLE `%s` CHARACTER SET utf8 COLLATE utf8_unicode_ci", $table));
                Symphony::Database()->query(sprintf("ALTER TABLE `%s` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci", $table));
            }
        }
        // [#1420] Change date field to be a varchar instead of an ENUM to support prepopulation
        try {
            Symphony::Database()->query('
					ALTER TABLE `tbl_fields_date`
					CHANGE `pre_populate` `pre_populate` varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL;
				');
        } catch (Exception $ex) {
        }
        // [#1997] Add filtering column to the Sections table
        if (!Symphony::Database()->tableContainsField('tbl_sections', 'filter')) {
            Symphony::Database()->query("\n\t\t\t\t\tALTER TABLE `tbl_sections`\n\t\t\t\t\tADD `filter` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'yes';\n\t\t\t\t");
        }
        $installed_extensions = Symphony::ExtensionManager()->listInstalledHandles();
        if (in_array('publishfiltering', $installed_extensions)) {
            Symphony::ExtensionManager()->uninstall('publishfiltering');
            self::$publish_filtering_disabled = true;
        }
        // [#1874] XSRF/CRSF options
        if (version_compare(self::$existing_version, '2.4beta3', '<=')) {
            // How long should a XSRF token be valid
            Symphony::Configuration()->set('token_lifetime', '15 minutes', 'symphony');
            // Should the token be removed as soon as it has been used?
            Symphony::Configuration()->set('invalidate_tokens_on_request', false, 'symphony');
        }
        // [#1874] XSRF/CRSF options
        if (version_compare(self::$existing_version, '2.4RC1', '<=')) {
            // On update, disable XSRF for compatibility purposes
            Symphony::Configuration()->set('enable_xsrf', 'no', 'symphony');
        }
        // Update the version information
        return parent::upgrade();
    }
开发者ID:valery,项目名称:symphony-2,代码行数:55,代码来源:2.4.0.php

示例7: upgrade

 public static function upgrade()
 {
     // 2.2.0dev
     if (version_compare(self::$existing_version, '2.2.0dev', '<=')) {
         Symphony::Configuration()->set('version', '2.2dev', 'symphony');
         if (Symphony::Database()->tableContainsField('tbl_sections_association', 'cascading_deletion')) {
             Symphony::Database()->query('ALTER TABLE `tbl_sections_association` CHANGE  `cascading_deletion` `hide_association` enum("yes","no") COLLATE utf8_unicode_ci NOT NULL DEFAULT "no";');
             // Update Select table to include the new association field
             Symphony::Database()->query('ALTER TABLE `tbl_fields_select` ADD `show_association` ENUM( "yes", "no" ) COLLATE utf8_unicode_ci NOT NULL DEFAULT "yes"');
         }
         if (Symphony::Database()->tableContainsField('tbl_authors', 'default_section')) {
             // Allow Authors to be set to any area in the backend.
             Symphony::Database()->query('ALTER TABLE `tbl_authors` CHANGE `default_section` `default_area` VARCHAR(255) COLLATE utf8_unicode_ci DEFAULT NULL;');
         }
         Symphony::Configuration()->write();
     }
     // 2.2.0
     if (version_compare(self::$existing_version, '2.2', '<=')) {
         Symphony::Configuration()->set('version', '2.2', 'symphony');
         Symphony::Configuration()->set('datetime_separator', ' ', 'region');
         Symphony::Configuration()->set('strict_error_handling', 'yes', 'symphony');
         // We've added UNIQUE KEY indexes to the Author, Checkbox, Date, Input, Textarea and Upload Fields
         // Time to go through the entry tables and make this change as well.
         $author = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_author`");
         $checkbox = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_checkbox`");
         $date = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_date`");
         $input = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_input`");
         $textarea = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_textarea`");
         $upload = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_upload`");
         $field_ids = array_merge($author, $checkbox, $date, $input, $textarea, $upload);
         foreach ($field_ids as $id) {
             $table = '`tbl_entries_data_' . $id . '`';
             try {
                 Symphony::Database()->query("ALTER TABLE " . $table . " DROP INDEX `entry_id`");
             } catch (Exception $ex) {
             }
             try {
                 Symphony::Database()->query("CREATE UNIQUE INDEX `entry_id` ON " . $table . " (`entry_id`)");
                 Symphony::Database()->query("OPTIMIZE TABLE " . $table);
             } catch (Exception $ex) {
             }
         }
     }
     // Update the version information
     return parent::upgrade();
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:46,代码来源:2.2.0.php

示例8: upgrade

 static function upgrade()
 {
     //  Update DB for the new Mime-type length. #1534
     if (version_compare(self::$existing_version, '2.3.2beta1', '<=')) {
         $upload_entry_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_upload`");
         if (is_array($upload_entry_tables) && !empty($upload_entry_tables)) {
             foreach ($upload_entry_tables as $field) {
                 Symphony::Database()->query(sprintf("ALTER TABLE `tbl_entries_data_%d` CHANGE `mimetype` `mimetype` varchar(100) DEFAULT NULL", $field));
             }
         }
     }
     // Reapply increase length of password field to accomodate longer hashes
     // fix as it looks like we created an error in the 2.3.1 migration. RE #1648
     Symphony::Database()->query("ALTER TABLE `tbl_authors` CHANGE `password` `password` VARCHAR( 150 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
     // Update the version information
     return parent::upgrade();
 }
开发者ID:valery,项目名称:symphony-2,代码行数:17,代码来源:2.3.2.php

示例9: upgrade

 public static function upgrade()
 {
     if (version_compare(self::$existing_version, '2.3.3beta1', '<=')) {
         // Update DB for the new author role #1692
         Symphony::Database()->query("ALTER TABLE `tbl_authors` CHANGE `user_type` `user_type` enum('author', 'manager', 'developer') DEFAULT 'author'");
         // Remove directory from the upload fields, #1719
         $upload_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_upload`");
         if (is_array($upload_tables) && !empty($upload_tables)) {
             foreach ($upload_tables as $field) {
                 Symphony::Database()->query(sprintf("UPDATE tbl_entries_data_%d SET file = substring_index(file, '/', -1)", $field));
             }
         }
     }
     if (version_compare(self::$existing_version, '2.3.3beta2', '<=')) {
         // Update rows for associations
         if (!Symphony::Configuration()->get('association_maximum_rows', 'symphony')) {
             Symphony::Configuration()->set('association_maximum_rows', '5', 'symphony');
         }
     }
     // Update the version information
     return parent::upgrade();
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:22,代码来源:2.3.3.php

示例10: upgrade

 public static function upgrade()
 {
     // Add association interfaces
     try {
         Symphony::Database()->query('
                 ALTER TABLE `tbl_sections_association`
                 ADD `interface` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
                 ADD `editor` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL;
             ');
     } catch (Exception $ex) {
     }
     // Remove show_association #2082
     try {
         Symphony::Database()->query('
                 ALTER TABLE `tbl_fields_select` DROP COLUMN show_association;
             ');
     } catch (Exception $ex) {
     }
     // Remove XSRF configuration options #2118
     Symphony::Configuration()->remove('token_lifetime', 'symphony');
     Symphony::Configuration()->remove('invalidate_tokens_on_request', 'symphony');
     // Update the version information
     return parent::upgrade();
 }
开发者ID:roshinebagha,项目名称:Symphony-Test,代码行数:24,代码来源:2.5.0.php

示例11: upgrade

    public static function upgrade()
    {
        // 2.2.1 Beta 1
        if (version_compare(self::$existing_version, '2.2.1 Beta 1', '<=')) {
            Symphony::Configuration()->set('version', '2.2.1 Beta 1', 'symphony');
            try {
                Symphony::Database()->query('CREATE INDEX `session_expires` ON `tbl_sessions` (`session_expires`)');
                Symphony::Database()->query('OPTIMIZE TABLE `tbl_sessions`');
            } catch (Exception $ex) {
            }
            Symphony::Configuration()->write();
        }
        // 2.2.1 Beta 2
        if (version_compare(self::$existing_version, '2.2.1 Beta 2', '<=')) {
            Symphony::Configuration()->set('version', '2.2.1 Beta 2', 'symphony');
            // Add Security Rules from 2.2 to .htaccess
            try {
                $htaccess = file_get_contents(DOCROOT . '/.htaccess');
                if ($htaccess !== false && !preg_match('/### SECURITY - Protect crucial files/', $htaccess)) {
                    $security = '
            ### SECURITY - Protect crucial files
            RewriteRule ^manifest/(.*)$ - [F]
            RewriteRule ^workspace/(pages|utilities)/(.*)\\.xsl$ - [F]
            RewriteRule ^(.*)\\.sql$ - [F]
            RewriteRule (^|/)\\. - [F]

            ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"';
                    $htaccess = str_replace('### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"', $security, $htaccess);
                    file_put_contents(DOCROOT . '/.htaccess', $htaccess);
                }
            } catch (Exception $ex) {
            }
            // Add correct index to the `tbl_cache`
            try {
                Symphony::Database()->query('ALTER TABLE `tbl_cache` DROP INDEX `creation`');
                Symphony::Database()->query('CREATE INDEX `expiry` ON `tbl_cache` (`expiry`)');
                Symphony::Database()->query('OPTIMIZE TABLE `tbl_cache`');
            } catch (Exception $ex) {
            }
            // Remove Hide Association field from Select Data tables
            $select_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_select`");
            if (is_array($select_tables) && !empty($select_tables)) {
                foreach ($select_tables as $field) {
                    if (Symphony::Database()->tableContainsField('tbl_entries_data_' . $field, 'show_association')) {
                        Symphony::Database()->query(sprintf("ALTER TABLE `tbl_entries_data_%d` DROP `show_association`", $field));
                    }
                }
            }
            // Update Select table to include the sorting option
            if (!Symphony::Database()->tableContainsField('tbl_fields_select', 'sort_options')) {
                Symphony::Database()->query('ALTER TABLE `tbl_fields_select` ADD `sort_options` ENUM( "yes", "no" ) COLLATE utf8_unicode_ci NOT NULL DEFAULT "no"');
            }
            // Remove the 'driver' from the Config
            Symphony::Configuration()->remove('driver', 'database');
            Symphony::Configuration()->write();
            // Remove the NOT NULL from the Author tables
            try {
                $author = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_author`");
                foreach ($author as $id) {
                    $table = '`tbl_entries_data_' . $id . '`';
                    Symphony::Database()->query('ALTER TABLE ' . $table . ' CHANGE `author_id` `author_id` int(11) unsigned NULL');
                }
            } catch (Exception $ex) {
            }
            Symphony::Configuration()->write();
        }
        // Update the version information
        return parent::upgrade();
    }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:69,代码来源:2.2.1.php

示例12: upgrade

 public static function upgrade()
 {
     // 2.3dev
     if (version_compare(self::$existing_version, '2.3dev', '<=')) {
         Symphony::Configuration()->set('version', '2.3dev', 'symphony');
         Symphony::Configuration()->set('useragent', 'Symphony/2.3dev', 'general');
         // Add Publish Label to `tbl_fields`
         if (!Symphony::Database()->tableContainsField('tbl_fields', 'publish_label')) {
             Symphony::Database()->query('ALTER TABLE `tbl_fields` ADD `publish_label` VARCHAR(255) DEFAULT NULL');
         }
         // Migrate any Checkbox's Long Description to Publish Label
         try {
             $checkboxes = Symphony::Database()->fetch("SELECT `field_id`, `description` FROM `tbl_fields_checkbox`");
             foreach ($checkboxes as $field) {
                 if (!isset($field['description'])) {
                     continue;
                 }
                 Symphony::Database()->query(sprintf("\n                            UPDATE `tbl_fields`\n                            SET `publish_label` = '%s'\n                            WHERE `id` = %d\n                            LIMIT 1;\n                            ", $field['description'], $field['field_id']));
             }
             Symphony::Database()->query("ALTER TABLE `tbl_fields_checkbox` DROP `description`");
         } catch (Exception $ex) {
         }
         // Removing unused settings
         Symphony::Configuration()->remove('allow_page_subscription', 'symphony');
         Symphony::Configuration()->remove('strict_error_handling', 'symphony');
         Symphony::Configuration()->remove('character_set', 'database');
         Symphony::Configuration()->remove('character_encoding', 'database');
         Symphony::Configuration()->remove('runtime_character_set_alter', 'database');
         if (Symphony::Configuration()->get('pagination_maximum_rows', 'symphony') == '17') {
             Symphony::Configuration()->set('pagination_maximum_rows', '20', 'symphony');
         }
         Symphony::Configuration()->write();
     }
     // 2.3 Beta 1
     if (version_compare(self::$existing_version, '2.3beta1', '<=')) {
         Symphony::Configuration()->set('version', '2.3beta1', 'symphony');
         Symphony::Configuration()->set('useragent', 'Symphony/2.3 Beta 1', 'general');
         Symphony::Configuration()->write();
     }
     // 2.3 Beta 2
     if (version_compare(self::$existing_version, '2.3beta2', '<=')) {
         // Migrate Publish Labels (if created) to the Label field
         // Then drop Publish Label, we're going to use element_name and label
         // to take care of the same functionality!
         try {
             if (Symphony::Database()->tableContainsField('tbl_fields', 'publish_label')) {
                 $fields = Symphony::Database()->fetch('SELECT `publish_label`, `label`, `id` FROM `tbl_fields`');
                 foreach ($fields as $field) {
                     if (!$field['publish_label']) {
                         continue;
                     }
                     Symphony::Database()->query(sprintf("\n                                UPDATE `tbl_fields`\n                                SET `label` = '%s'\n                                WHERE `id` = %d\n                                LIMIT 1;\n                                ", $field['publish_label'], $field['id']));
                 }
                 Symphony::Database()->query("ALTER TABLE `tbl_fields` DROP `publish_label`");
             }
         } catch (Exception $ex) {
             Symphony::Log()->pushToLog($ex->getMessage(), E_NOTICE, true);
         }
         // Add uniqueness constraint for the Authors table. #937
         try {
             Symphony::Database()->query("ALTER TABLE `tbl_authors` ADD UNIQUE KEY `email` (`email`)");
         } catch (DatabaseException $ex) {
             // 1061 will be 'duplicate key', which is fine (means key was added earlier)
             // 1062 means the key failed to apply, which is bad.
             // @see http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
             if ($ex->getDatabaseErrorCode() === 1062) {
                 Symphony::Log()->pushToLog(__("You have multiple Authors with the same email address, which can cause issues with password retrieval. Please ensure all Authors have unique email addresses before updating. " . $ex->getMessage()), E_USER_ERROR, true);
                 return false;
             }
         }
         // Update the version information
         Symphony::Configuration()->set('version', '2.3beta2', 'symphony');
         Symphony::Configuration()->set('useragent', 'Symphony/2.3 Beta 2', 'general');
         Symphony::Configuration()->write();
     }
     // 2.3 Beta 3
     if (version_compare(self::$existing_version, '2.3beta3', '<=')) {
         // Refresh indexes on existing Author field tables
         $author_fields = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_author`");
         foreach ($author_fields as $id) {
             $table = 'tbl_entries_data_' . $id;
             // MySQL doesn't support DROP IF EXISTS, so we'll try and catch.
             try {
                 Symphony::Database()->query("ALTER TABLE `" . $table . "` DROP INDEX `entry_id`");
             } catch (Exception $ex) {
             }
             try {
                 Symphony::Database()->query("CREATE UNIQUE INDEX `author` ON `" . $table . "` (`entry_id`, `author_id`)");
                 Symphony::Database()->query("OPTIMIZE TABLE " . $table);
             } catch (Exception $ex) {
             }
         }
         // Move section sorting data from the database to the filesystem. #977
         if (Symphony::Database()->tableContainsField('tbl_sections', 'entry_order')) {
             $sections = Symphony::Database()->fetch("SELECT `handle`, `entry_order`, `entry_order_direction` FROM `tbl_sections`");
             foreach ($sections as $s) {
                 Symphony::Configuration()->set('section_' . $s['handle'] . '_sortby', $s['entry_order'], 'sorting');
                 Symphony::Configuration()->set('section_' . $s['handle'] . '_order', $s['entry_order_direction'], 'sorting');
             }
         }
//.........这里部分代码省略.........
开发者ID:roshinebagha,项目名称:Symphony-Test,代码行数:101,代码来源:2.3.0.php


注:本文中的Migration::upgrade方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。