Trouble with upgrade paths from different branches
Hello. I am having trouble with hook_update_N(). My module (yr_verdata) has two branches for D6, and I want to provide an upgrade path from both of these to D7. However, I can't seem to get the correct schema version when upgrading. In my install file i have the following: function yr_verdata_update_7000(&$sandbox) { // Check to see what schema we are updating from. // If we are going from 6.x-2.x to 7.x-1.x, the schema is already ready for // 7.x-1.x so we just update the schema version number. $version = drupal_get_installed_schema_version('yr_verdata', TRUE); if ($version > 6199) { // Updating from 6.x-2.x, no problem. drupal_set_installed_schema_version('yr_verdata', 7000); } else { // Updating from 6.x-1.x, modify the database table. // Some update logic. } return t('Some friendly message'); } The problem here is that drupal_get_installed_schema_version() simply returns 6999, no matter what. What am I doing wrong? I could just remove the update logic that messes with the database table from the 7.x branch doing it all in 6.x-2.x, and require 6.x-1.x users to upgrade to 6.x-2.x before going to 7.x-1.x - but that sounds like a bad idea to me, and just extra work for people who want to upgrade to D7 with this module. Any help is appreciated!
I believe it returns 6999, because the first allowed update revision in D7 is 7000. I agree that it should return the currently installed schema version, but it is what it is until it is patched - perhaps an issue is warranted? I would suggest releasing new version of your D6 branches that sets a variable, perhaps 'yr_verdata_d6_version', to '1' or '2' depending on your branch. Then in yr_verdata_update_7000(), just check the value of this variable, perform the schema update if necessary, then delete the variable again. Or you could just add the variable to your deprecated 6.x-1.x branch. As long as you make it clear on the project page that the user *must* upgrade to the latest version of the 6.x-1.x branch before upgrading to D7, you should be covered against breakage on user sites. Brian On 11-02-19 07:58 AM, Fredrik Sandve Kilander wrote:
Hello. I am having trouble with hook_update_N(). My module (yr_verdata) has two branches for D6, and I want to provide an upgrade path from both of these to D7. However, I can't seem to get the correct schema version when upgrading. In my install file i have the following:
function yr_verdata_update_7000(&$sandbox) {
// Check to see what schema we are updating from. // If we are going from 6.x-2.x to 7.x-1.x, the schema is already ready for // 7.x-1.x so we just update the schema version number. $version = drupal_get_installed_schema_version('yr_verdata', TRUE);
if ($version> 6199) { // Updating from 6.x-2.x, no problem. drupal_set_installed_schema_version('yr_verdata', 7000); }
else { // Updating from 6.x-1.x, modify the database table. // Some update logic. }
return t('Some friendly message');
}
The problem here is that drupal_get_installed_schema_version() simply returns 6999, no matter what. What am I doing wrong?
I could just remove the update logic that messes with the database table from the 7.x branch doing it all in 6.x-2.x, and require 6.x-1.x users to upgrade to 6.x-2.x before going to 7.x-1.x - but that sounds like a bad idea to me, and just extra work for people who want to upgrade to D7 with this module.
Any help is appreciated!
participants (2)
-
Brian Vuyk -
Fredrik Sandve Kilander