Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Some databases that came from old Drupal installations seem to have a small {system}.weight
. For example, on Drupal.org:
weight tinyint(3) unsigned
This breaks the upgrade process from Drupal 6 to Drupal 7 where we bump some modules to a weight > 1000.
Comment | File | Size | Author |
---|---|---|---|
#17 | 601642_followup.patch | 1.27 KB | andypost |
#15 | fixsystemweight.patch | 2.06 KB | catch |
#11 | fixsystemweight_03.patch | 2.03 KB | ctmattice1 |
#9 | fixsystemweight_02.patch | 2.23 KB | ctmattice1 |
#7 | fixsystemweight_01.patch | 2.17 KB | ctmattice1 |
Comments
Comment #1
ctmattice1 CreditAttribution: ctmattice1 commentedI have a patch that fixes this problem. Here is the text for further discussion as it may not be optimized.
The database I use is mysql v5.1.33 with php 5.2.9 which is a standard install of xampp 1.7.1 on vista. It get's through the system updates ok till the point where it attempts to update contrib modules. At this point I run into errors with registry.inc and non-existent paths.
Index: includes/update.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/update.inc,v
retrieving revision 1.12
diff -u -p -r1.12 update.inc
--- includes/update.inc 3 Oct 2009 20:17:46 -0000 1.12
+++ includes/update.inc 11 Oct 2009 20:06:05 -0000
@@ -123,6 +123,21 @@ function update_fix_d7_requirements() {
file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ';', FILE_APPEND);
}
if (drupal_get_installed_schema_version('system') < 7000 && !variable_get('update_d7_requirements', FALSE)) {
+
+ // Change 6.x system table field lenght values to 7.x equivelent
+ db_change_field('system', 'status', 'status',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'bootstrap', 'bootstrap',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'weight', 'weight',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'schema_version', 'schema_version',
+ array('type' => 'int',
+ 'size' => 'small',
+ 'length' => 6,
+ 'not null' => TRUE,
+ 'default' => -1));
+
// Add the cache_path table.
$schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_path']['description'] = 'Cache table used for path alias lookups.';
@@ -133,6 +148,13 @@ function update_fix_d7_requirements() {
db_add_field('locales_source', 'context', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'The context this string applies to.'));
}
+ // role_premissions table is required now by user.modlue
+ update_fix_d7_role_permissions();
+
+ //registry is also required now
+ update_fix_d7_registry();
+
+
// Rename 'site_offline_message' variable to 'maintenance_mode_message'.
// Old variable is removed in update for system.module.
// @see system_update_7036().
@@ -213,6 +235,72 @@ function update_fix_d7_install_profile()
}
}
+function update_fix_d7_role_permissions() {
+ $schema['role_permission'] = array(
+ 'fields' => array(
+ 'rid' => array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ ),
+ 'permission' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ ),
+ 'primary key' => array('rid', 'permission'),
+ 'indexes' => array(
+ 'permission' => array('permission'),
+ ),
+ );
+
+ db_create_table('role_permission', $schema['role_permission']);
+
+}
+
+function update_fix_d7_registry() {
+ $schema['registry'] = array(
+ 'fields' => array(
+ 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'type' => array('type' => 'varchar', 'length' => 9, 'not null' => TRUE, 'default' => ''),
+ 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ ),
+ 'primary key' => array('name', 'type'),
+ 'indexes' => array(
+ 'hook' => array('type', 'weight', 'module'),
+ ),
+ );
+ $schema['registry_file'] = array(
+ 'fields' => array(
+ 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+ 'filectime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'filemtime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ ),
+ 'primary key' => array('filename'),
+ );
+ $schema['cache_registry'] = array(
+ 'fields' => array(
+ 'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
+ 'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'headers' => array('type' => 'text', 'not null' => FALSE),
+ 'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
+ ),
+ 'indexes' => array('expire' => array('expire')),
+ 'primary key' => array('cid'),
+ );
+ db_create_table('cache_registry', $schema['cache_registry']);
+ db_create_table('registry', $schema['registry']);
+ db_create_table('registry_file', $schema['registry_file']);
+}
+
+
+
/**
* Parse database connection URLs (in the old, pre-Drupal 7 format) and
* return them as an array of database connection information.
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.395
diff -u -p -r1.395 system.install
--- modules/system/system.install 5 Oct 2009 04:34:04 -0000 1.395
+++ modules/system/system.install 11 Oct 2009 20:49:20 -0000
@@ -1782,45 +1782,53 @@ function system_update_7005() {
* longer needed.
*/
function system_update_7006() {
- $schema['registry'] = array(
- 'fields' => array(
- 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
- 'type' => array('type' => 'varchar', 'length' => 9, 'not null' => TRUE, 'default' => ''),
- 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
- 'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
- 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
- ),
- 'primary key' => array('name', 'type'),
- 'indexes' => array(
- 'hook' => array('type', 'weight', 'module'),
- ),
- );
- $schema['registry_file'] = array(
- 'fields' => array(
- 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
- 'filectime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
- 'filemtime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
- ),
- 'primary key' => array('filename'),
- );
- $schema['cache_registry'] = array(
- 'fields' => array(
- 'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
- 'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
- 'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
- 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
- 'headers' => array('type' => 'text', 'not null' => FALSE),
- 'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
- ),
- 'indexes' => array('expire' => array('expire')),
- 'primary key' => array('cid'),
- );
- db_create_table('cache_registry', $schema['cache_registry']);
- db_create_table('registry', $schema['registry']);
- db_create_table('registry_file', $schema['registry_file']);
+ // Check to see if it was already run by update_fix_d7_requirements()
+ if (!db_table_exists('registry')) {
+ $schema['registry'] = array(
+ 'fields' => array(
+ 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'type' => array('type' => 'varchar', 'length' => 9, 'not null' => TRUE, 'default' => ''),
+ 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'module' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ ),
+ 'primary key' => array('name', 'type'),
+ 'indexes' => array(
+ 'hook' => array('type', 'weight', 'module'),
+ ),
+ );
+ db_create_table('registry', $schema['registry']);
+ }
+ if (!db_table_exists('registry_file')) {
+ $schema['registry_file'] = array(
+ 'fields' => array(
+ 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+ 'filectime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'filemtime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ ),
+ 'primary key' => array('filename'),
+ );
+ db_create_table('registry_file', $schema['registry_file']);
+ }
+ if (!db_table_exists('cache_registry')) {
+ $schema['cache_registry'] = array(
+ 'fields' => array(
+ 'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+ 'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
+ 'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'headers' => array('type' => 'text', 'not null' => FALSE),
+ 'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
+ ),
+ 'indexes' => array('expire' => array('expire')),
+ 'primary key' => array('cid'),
+ );
+ db_create_table('cache_registry', $schema['cache_registry']);
+ }
registry_rebuild();
}
+
/**
* Convert to new method of storing permissions.
*
@@ -1828,27 +1836,30 @@ function system_update_7006() {
* all modules can use the updated permission scheme during their updates.
*/
function system_update_7007() {
- $schema['role_permission'] = array(
- 'fields' => array(
- 'rid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
+ // Check to see if it was already run by update_fix_d7_requirements()
+ if (!db_table_exists('role_permission')) {
+ $schema['role_permission'] = array(
+ 'fields' => array(
+ 'rid' => array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ ),
+ 'permission' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ ),
+ 'primary key' => array('rid', 'permission'),
+ 'indexes' => array(
+ 'permission' => array('permission'),
),
- 'permission' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- ),
- ),
- 'primary key' => array('rid', 'permission'),
- 'indexes' => array(
- 'permission' => array('permission'),
- ),
- );
+ );
- db_create_table('role_permission', $schema['role_permission']);
+ db_create_table('role_permission', $schema['role_permission']);
+ }
// Copy the permissions from the old {permission} table to the new {role_permission} table.
$messages = array();
Index: modules/upload/upload.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.install,v
retrieving revision 1.15
diff -u -p -r1.15 upload.install
--- modules/upload/upload.install 29 Sep 2009 15:13:57 -0000 1.15
+++ modules/upload/upload.install 11 Oct 2009 20:28:26 -0000
@@ -97,7 +97,7 @@ function upload_update_7000(&$sandbox) {
// As a batch operation move records from {files} into the {file} table.
$limit = 500;
- $result = db_query_range("SELECT DISTINCT u.fid FROM {upload} u ORDER BY u.vid", array(), 0, $limit);
+ $result = db_query_range("SELECT DISTINCT u.fid FROM {upload} u ORDER BY u.vid", 0, $limit, array());
foreach ($result as $record) {
$old_file = db_query('SELECT f.* FROM {files} f WHERE f.fid = :fid', array(':fid' => $record->fid))->fetch(PDO::FETCH_OBJ);
if (!$old_file) {
Comment #2
mikey_p CreditAttribution: mikey_p commentedtagging
Comment #3
sun.core CreditAttribution: sun.core commented.
Comment #4
ctmattice1 CreditAttribution: ctmattice1 commentedIdeally what should be done is to convert the 6.x system field values to match those of D7. What reason would there be on an upgrade not to do this. This will not break any 6.x sites doing this in case the update fails down stream.
Please review the following code, it does not use $schema as the table only need modification. I'm wonder though why D7 carries a int 11 in weights this seems a little high and would probably make more sense to use a small init 6 as in the schema_version field.
Index: includes/update.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/update.inc,v
retrieving revision 1.31
diff -u -p -r1.31 update.inc
--- includes/update.inc 25 Jan 2010 10:38:34 -0000 1.31
+++ includes/update.inc 27 Jan 2010 00:45:47 -0000
@@ -266,6 +266,19 @@ function update_fix_d7_requirements() {
file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ";\n\$drupal_hash_salt = '$salt';", FILE_APPEND);
}
if (drupal_get_installed_schema_version('system') < 7000 && !variable_get('update_d7_requirements', FALSE)) {
+ // Change 6.x system table field values to 7.x equivelent
+ db_change_field('system', 'status', 'status',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'bootstrap', 'bootstrap',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'weight', 'weight',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'schema_version', 'schema_version',
+ array('type' => 'int',
+ 'size' => 'small',
+ 'length' => 6,
+ 'not null' => TRUE,
+ 'default' => -1));
// Add the cache_path table.
$schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_path']['description'] = 'Cache table used for path alias lookups.';
Patch attached based on yesterday's HEAD
Comment #6
chx CreditAttribution: chx commented#612870: Weight fields should be int, not tinyint
Comment #7
ctmattice1 CreditAttribution: ctmattice1 commentedI see where there is similarities with #612870: Weight fields should be int, not tinyint and it has been committed. however, there is one table that still needs correction in addition to those, the system table, without fixing it there are some upgrades from d6 to d7 that will fail immediately. I've attached a corrected patch to fix it.
Comment #8
catchYes system was missing from the other patch.
Should be "equivalent", also comments should be sentence case and include a period, and above the code they describe rather than inline on the same line - see http://drupal.org/coding-standards
Additionally, where we're dropping and recreating the same index - could we put those statements next to each other?
Looks like the path index comment appears twice in the patch?
Powered by Dreditor.
Comment #9
ctmattice1 CreditAttribution: ctmattice1 commentedCorrected patch as catch suggested. Fixed modules index where bootstrap field should not have been present.
Comment #10
Magnity CreditAttribution: Magnity commentedDuplicated code?
Powered by Dreditor.
Comment #11
ctmattice1 CreditAttribution: ctmattice1 commentedHmmm, missed that one. Stupid copy and paste error a couple patches ago. My Bad
Comment #12
catchLooks good now.
Comment #13
aaron CreditAttribution: aaron commentedsubscribe
Comment #14
webchickThis seems to have some comment indentation issues, and also warns me about fuzz when I apply it. I can haz re-roll?
Comment #15
catchYou can haz.
Also this really is critical - no Drupal 5 site can upgrade to Drupal 7 without this patch afaik.
Comment #16
webchickAwesome, thanks. Committed to HEAD!
Comment #17
andypostWhat's 'lenght' parameter means for INT data-type? Is this mysql specific? Suppose no!
Here is a patch to remove length from schema definition.
Comment #18
webchickOops. :P
Thanks, committed to HEAD. :)