Use case: run drush sup. Find a bug in a module. Fix it. Changes happen on live site. Run drush sup again; this time you want to keep the code you fixed from last time rather than download new code.
This patch also makes si upgrade to 7.0 (whatever is recommended) rather than 7.x (head).
Probably close, but I need to test it more.
Edit: Fixed typo; said 'si' where it should have said 'sup'; this issue is about site-upgrade, not site-install.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | sup-28.patch | 44.61 KB | greg.1.anderson |
| #26 | sup-26.patch | 38.75 KB | greg.1.anderson |
| #25 | sup-25.patch | 37.52 KB | greg.1.anderson |
| #22 | drush-sup-22.patch | 31.41 KB | greg.1.anderson |
| #20 | sup.patch | 29.66 KB | greg.1.anderson |
Comments
Comment #1
greg.1.anderson commentedThis patch does quite a lot.
First off, a bug is fixed with non-core modules. The current version of sup tries to download the 7.x version of a module using its module name instead of its project name. With this patch, the project name is looked up from the module name first.
Also, a translation table for projects is introduced. The upgrade information from http://drupal.org/node/895314 is now encoded into drush site-upgrade. If you are using a d6 contrib module that is now standard in core, sup will no longer attempt to download it. sup can also now handle projects that change names in d7 (don't know of any), and it can handle modules that change names (like content -> cck). Also, if a given module needs any special action (e.g. special steps to do data conversion), sup now warns the user about that up-front too. If you have any warnings, you will be prompted before the upgrade begins.
sup now upgrades to the recommended release of Drupal 7.x rather than the latest dev release.
sup now enables the optional core modules that were enabled in the source site.
As mentioned above, you can run sup more than once on the same site, keeping the same code every time (e.g. if you made fixes to a contrib module, or perhaps checked in the upgraded site to a vcs, and then later want to check out the code and use sup to pull in and re-upgrade the db, etc.)
Tested and seems to work pretty well.
Comment #2
mlncn commentedFor running site-upgrade, site-upgrade still gives three options:
And on picking [2]
Move /home/ben/code/anjali7/web/sites/all/modules to [ok]
/home/ben/code/anjali7/web/sites/all/sites_all_modulesYhD1Pv prior to
updatedb on Drupal core.
What is it doing that i don't get from putting the D6 database right into D7? And is it affecting the database of the site i'm starting from? if so, that should be noted.
Also i'm getting access denied for my user on that database, but i'm sure that's my problem-- i guess it's trying to drop the database?
i'll be back with more useful input soon i hope
Comment #3
greg.1.anderson commentedDrush si does not affect the database on the source side. You can use --db-su and --db-su-pw to specify the username and password of the database superuser if you have having permission problems.
Comment #4
mlncn commentedbut does drush upgrade-site affect its source site? i'm trying to figure out how vigorously i need to clean every database related before trying again.
i can't get an upgrade to run any which way this week. Last week i was able to do so with drush updatedb. All we've done is *disable* modules on the source site, yet that's the one thing that's changed.
So can't for the life of me figure out what's up.
repeatedly getting a table role_permission already exists error.
and last try from the d6 site (with the strange path in the command being where i installed drush master and patched it with this patch) --
/home/ben/code/anjali7/drush/drush site-upgrade @anjali.dev7 --db-su root --db-su-pw toor --no-cacheis hanging, for the past hour or so.
Comment #5
greg.1.anderson commentedThere isn't enough information in your post for me to help you with your problem. Please do not put any more support requests on this issue; I would like to keep this thread limited to testing this patch. Make a new issue, and follow the reporting guidelines at the top of the page.
Comment #6
mlncn commentedYeah, sorry about that. Started:
#1074670: What does / should site-upgrade do to the source site? Are any changes made there (and can it be avoided)?
#1074696: Is sql-sync and/or sql-dump leaving out or adding tables or something when passed with no
Comment #7
mlncn commentedApologies, i wasted your time and mine because i somehow dirtied my source site DB, and didn't wipe the tables before pulling it fresh (or so i thought) from production.
Apologies also, i'm testing site-upgrade and not site-install directly.
When running the patched Drush:
drush --debug site-upgrade @anjali.dev7Immediately after the database drop and import succeeds:
I don't think it's a permissions issue, the copy command seems to be missing it's variables.
Comment #8
greg.1.anderson commentedBy the log above (Calling copy(, sites//settings.php)), your configuration does not appear to be correct. Please post a new issue for your support request, and include the definition of your d7 alias.
Comment #9
greg.1.anderson commentedSorry, #1 was missing its patch file, and I did not notice. The patch in #0 does not work! Try this one.
Comment #10
mlncn commentedIt runs!
Feature request: be able to tell it not to try to download any contrib modules. It checks for every one, asks you to pick which one to download (i haven't tried yet in this version but 0 to cancel at this point canceled the whole script last version), and only then notices it already exists, and asks if you want to override it. Answering n works great at this point but the entire loop of even checking for any of them could be skipped after first time.
Comment #11
greg.1.anderson commentedThat's a lot of prompting. As a workaround, make a copy of your live site, and upgrade that, first disabling any module that you don't want to pull over. Site-upgrade will only upgrade enabled modules.
Comment #12
greg.1.anderson commentedI have updated https://github.com/greg-1-anderson/drush-dgd7-scripts to include scripts 06-01 and 06-02 to test site-upgrade; still working well. I know the unit tests still need to be updated, but perhaps these will help. You can run 06-01 without any prior initialization; 06-02 will only run immediately after 06-01.
Side note about the patch names: I often typo and say si (site-install) when I mean sup (site-upgrade) -- I don't know why. For the avoidance of doubt, these patches affect only site-upgrade, not site-install.
I'm updating the status per #10; I think that once the unit tests are fixed, this should be ready to go in.
Comment #13
moshe weitzman commentedWill test this out now. First, some impressions and a code review ...
I'm concerned at how complex this command callback is getting. For example, I don't know that the map in _drush_upgrade_special_projects() is workable. The cck project lives on in D7 just to carry the update functions needed to move to Field API in D7. This pattern is not uncommon. In general, I'm fine with a log msg that states that 'no release available for abssrc'. I think we need to assume that the drush user has good Drupal knowledge.
Sentences should end with period. Happens a few times.
Why do we offer an option about target version. Aren't we always expecting user to upgrade from a working site? The target has to be the next major version, no?
How is different from specifying drupal-6.x? Are we trying to help folks who are rarely work with 7 but frequently work outside of a drupal site? I guess there is some value there.
Comment #14
greg.1.anderson commentedTo answer your last two questions:
drush dl drupal-6.xdownloads 6.x-dev.drush dl drupal --drupal-version-major=6downloads 6.20, the most recent recommended release.The call to drush_set_option is to pass $target_version (at this point, always "7") to
drush dl drupal. I could rework --drupal-version-major to instead be "--recommended".Comment #15
moshe weitzman commentedHmm. For Drush5, we should consider making dl drupal-6.x download latest recommended and requiring same plus --dev for dev snapshot. that makes the most sense to me.
Comment #16
greg.1.anderson commentedHm, I just tried
drush dl cck-6.xanddrush dl cck-6.x --dev, and it already behaves as you describe, pulling down the recommended and development releases, respectively. Given that, it really makes sense that dl drupal should work the same way.One question, though, is if this change (
drush dl drupal-6.xnow means 'recommended' instead of 'dev') is too harsh to backport to drush-4.x. It is a change in behavior, but one that people are not too likely to be using or depending on much. Maybe it is okay for 4.x? Definitely should be done for HEAD.Comment #17
moshe weitzman commentedI am seeing multiple instances of this error:
I saw it happen with the imagefield module, the content module, and date_api module. Not sure why these extensions don't know what their project is.
drush_pm_download('drupal');is asking me to confirm 'Install location /Users/mw/htd/sup7 already exists. Do you want to overwrite it? (y/n):'. I've already answered that question earlier (replace).drush_invoke('sql-sync', '@self', $target_key);should run with --yes so we don't ask 'do you want to continue'drush_log(dt("Disable non-core extensions. Could we change to 'Disabling' instead so it is more clear what action we are taking..
These happen during the call to site-upgrade-modules.
Comment #18
greg.1.anderson commentedOkay, I'll look into those. Could you give me the full list of non-core enabled modules on the site you are upgrading?
Comment #19
moshe weitzman commented- the date_* modules come from the date project.
- dbtng is from http://drupal.org/project/dbtng and obviously that module is in core now.
Comment #20
greg.1.anderson commentedWhen I try to run site-upgrade with those modules, I get:
This error prevents the updatedb from finishing. This problem is described here: #1013034: PostgreSQL constraints do not get renamed by db_rename_table(). I haven't tested with mysql yet; maybe this is postgres-specific.It is caused because date_formats is now defined in system/system.install's schema; we can't fix it with an update function in the date module that defines the table, because we can't call contrib update functions until updatedb has been run on Drupal core, and that is what is failing here.
I'm not sure how to resolve this problem. I don't think it would be right to have drush work around problems in the upgrade path of contrib modules. I added a warning to the sup warning table advising the user to disable and uninstall date_api until this problem is fixed. Perhaps sup should also have an --uninstall option, so the users can list modules to uninstall prior to upgrade w/out affecting their d6 site.
The attached patch should resolve the other issues mentioned in #17, except for --drupal-major-version, which still needs to be adjusted. In the meantime, suggestions on handling date_api are appreciated.
Comment #21
moshe weitzman commentedi like the --uninstall option.
Comment #22
greg.1.anderson commentedThis adds the --uninstall option, and removes --drupal-major-version. Now,
drush dl drupal-6will download the latest version of Drupal 6.x. This only works for Drupal core; version parsing for extensions is unchanged.--simulate not supported by sup yet; I think that's about the last thing remaining.
Comment #23
moshe weitzman commentedNot so sure about adding drupal-6. I think we should change what 6.x does. It should get latest recommended and then we expect folks to use --dev if they want snapshot. We can do that in a later patch so this one stays backportable.
Still need a hook in _drush_upgrade_special_projects() for commandfiles to alter the map.
For code comments, lets use start with a Capital and end with a period. Just change the ones you come across. I know that we are not consistent with this in this file or in many others in drush.
We can do --simulate in a follow up patch.
Will test later today.
Comment #24
greg.1.anderson commentedAlso needs
if (drush_get_error()) { return ; }in a few places.Comment #25
greg.1.anderson commentedAdded a hook drush_upgrade_project_map_alter that allows a module to add warning messages and such to the upgrade project map. Documented it in drush.api.php.
Fixed up the comments, and improved error recovery (e.g. if updatedb fails).
--simulate still not supported.
Comment #26
greg.1.anderson commentedFurther factored so that contrib modules are disabled in a separate command, site-upgrade-prepare, so that modules may hook this command to do their own upgrade preparatory steps. Documented hook in drush.api.php.
Comment #27
moshe weitzman commentedThis patch review is based on a couple patches ago ...
. We should be more clear about what we expect admin to do. I guess they need to enable content_migrate *after* sup has run?
If this happens, disable and uninstall the date_api module before running site-upgrade.. We can recommend --uninstall instead now.Comment #28
greg.1.anderson commented1. Fixed.
2. Made some progress toward breaking up drush_upgrade_site_upgrade; could benefit from more work here. I think if the 'WARN' section were broken out, this routine would be in pretty good shape.
3. Fixed.
4. This is a little complicated; I added a reference to http://drupal.org/node/781088.
5. Fixed.
6. Fixed.
7. No time to address this now; will need to return to it later.
8. Fixed.
9. Sure, and I can adjust iq-diff as well; this is actually my preference, to maintain the same convention for patches as existed prior to the git migration. However, the git instructions do not give this same advice. Should we perhaps post an issue in project_project, or wherever it is that the git instructions live?
--simulate is supported in this patch, but note that in simulate mode, neither site-upgrade-prepare nor site-upgrade-modules are actually called. Both of these bootstrap to sites that are not actually created in --simulate mode. This means that you won't see all of the operations happening during a site-upgrade with --simulate, but there's not much to do about that.
Edit: I realised after the fact that the comment above about --no-prefix was intended to refer to only git diff, and not to git format-patch, ergo my comment #9 above is incorrect.
Comment #29
greg.1.anderson commentedComment #30
moshe weitzman commentedTested it out and am happy enough with it. Feel free to commit and keep working on trimming down that giant function and other todos. I will commit soon if greg does not. On my way to Chicago now.
Comment #31
greg.1.anderson commentedCommitted #28. Probably want #30 before backporting.
Comment #32
greg.1.anderson commentedCommitted changes per #30.
Comment #33
msonnabaum commentedComment #34
moshe weitzman commentedReopening for a few minor things:
The project drupal has no releases in version 7. We don't remove drupal from the array of contrib projects.Undefined index: name in sitealias.inc on line 664.. $all_site_aliases['@self'] has no 'name'.Comment #35
mlncn commentedWith the goal of having a script to call that takes a site through a full upgrade based on update code in the site repository, this Drush script re-implements most of site-upgrade without the downloads or the project status/warning messages:
http://drupal.org/sandbox/mlncn/1154002
Definitely want to refactor drush sup to be able to run this way, or to share code with a function that does this.
Comment #36
mlncn commented[UPDATE: ignore the sleep-deprived fool, this code works fine.] Also, this code in site-upgrade does not blow away the target database for me. I'm assuming it's something in my set-up (perhaps same issue as #1110044: How to tell site-install to use the database root user for creating the database?), but it's important for Drush to flag when it is not able to delete the current database.
Comment #37
mlncn commentedThe last comment, aside from being off-topic, is wrong-- that code does wipe the database clean... when i look at the correct database.
And the script i posted is pretty unnecessary. This is probably what Greg meant in #11 and something like the below works quite well:
An option that we could pass into site-upgrade in place of core-only that a) skips the contrib module recommendations step (as core only does) and b) removes the download list before calling site-upgrade-modules would be ideal. The two-step approach here loses the modules to enable step but i sort of want to script manually that anyway.
Comment #38
greg.1.anderson commentedYour goals sound reasonable, but I'm not completely sure what you are suggesting. Do you think you could post a quick patch to
supthat shows what you mean? --core-only already skips site-upgrade-modules. When you say 'skips the contrib module recommendations step', do you mean that you want to upgrade some, but not all modules?Comment #39
mlncn commentedI would like to do what the above two commands do in one step. If the full site-upgrade has already been run once, all the modules we want in code have already been suggested and downloaded-- all that should be skipped.
Essentially a --reuse-ALL option that acts like --core-only except that it calls site-upgrade-modules with the list of previously disabled modules to re-enable.
I think i would be able to do a patch that extends the if statements, but first, does anyone have a use case for the present behavior of --reuse (which honors core but acts like contrib is still an open question), or can i simply change its behavior to expect to reuse all present code?
Comment #40
greg.1.anderson commentedDoes #39 mean that
drush site-upgrade @anjali.dev7 --reuse --uninstall=hashcash,develdoes not work correctly? That should do what you want, I think. The flag --core-only is supposed to skip contrib; are you using --core-only to work around some other bug?Comment #41
mlncn commentedYes, i'm using
--core-onlyand thensite-upgrade-modulesas a separate command to work around a bug where even though the --reuse flag is given, a number of prompts are given related to contrib modules.If i'm re-using code, i don't want that prompt. More importantly, if i'm re-using code, i don't want it to ask me if i want to download every contrib module. I already have them. It shouldn't even try. And boy, does it try:
Would a patch giving --reuse this meaning, no attempts to check or download contrib code, be accepted?
Comment #42
greg.1.anderson commentedThat sounds like a bug; it is supposed to work the way you describe. I thought it used to work; I'll take a look.
Comment #43
greg.1.anderson commentedShould really look at this again for the 'second run' use case. If our intention is really to simply re-use the same code as last time, it seems like we should only do the sql-sync and updatedb steps. Site-upgrade goes out of its way to run updatedb once without any contrib code present, as the presence of contrib code, even in the form of disabled modules, caused the upgrade process to go awry prior to Drupal-7.0 final. Perhaps this is better now; if so, this code could be simplified.
See also the following useful blog post: http://www.group42.ca/drupal_7_upgrades_scripts_drush
Comment #44
greg.1.anderson commentedMoving to drush_sup queue
Comment #45
greg.1.anderson commentedThis now works in the master branch. I have not published a release for master yet, though, so there is no applicable version in the issue queue. That will be resolved shortly, as I expect to be ready to publish master soon.
Comment #46
Joel MMCC commentedGreg, any update on when this will be in the master branch?
Comment #47
greg.1.anderson commentedSince there is no release for the master branch, using
drush dl drush_supwill always give you the 1.x branch (the original implementation from Drush core). However, it is possible to look at the master branch if you do a git clone following the instructions given on the version control instructions.I was waiting for a release of uuid-6.x-1.0-beta3 before publishing a release of the master branch, but it looks like that is blocked on some critical issues in the 6.x branch that no one is working on right now, so I may need to relent. If you are using features, update to the latest version of uuid-6.x-dev and run updatedb before starting your major upgrade. See #1149546: Please release 6.x-beta3, as it is not possible to upgrade to Drupal-7.x if uuid-6.x-beta2 is installed and #1482586: Upgrading from UUID 6.x to 7.x, and from 7.x-1.0-alpha1 to later versions.
There is also a bug in Drupal core that I have not had a chance to work on, although David Reid has helped push it forward. If you have the token module enabled in your D6 site (likely), you will get an error when you run the Drush site-upgrade command. If this happens, just run
drush updatedbagain on the target site, and then re-run the drush site-upgrade command, instructing it to pick up again where it left off, and the upgrade should work fine.I have not finished my D7 upgrade yet -- still need to finish my D7 theme -- but the code here does go through the upgrade steps successfully, save for the above-mentioned disclaimers. With enough positive feedback here, I might go ahead and pubish a release from the code in the master branch.
Comment #48
greg.1.anderson commentedAnother thing of note: if your site upgrade is going to be protracted, re-doing your post-upgrade tasks (migrating content types, fixing up configuration changes, etc.) every time you synchronize your database might become tedious. Rather than re-running Drush site-upgrade and re-doing this work, you might also consider drupal-to-drupal migration instead. If this is supported in enough contrib modules, perhaps Drush site-upgrade could even set it up for you, maybe in the future for D7 - D8 upgrades. For now, though, you will have to weigh the effort of setting up a migration against the number of times you expect to re-import your database.
Side note: setting the status of this to 'needs review', per #45 and #47. Community feedback would be nice; but if I don't get any, I will still publish a release of the master branch after I finish my D7 upgrade.
Comment #49
Joel MMCC commentedThanks for the info.
Comment #50
Joel MMCC commentedOops, forgot to mention: we don’t use the UUID module (didn’t even know it existed until I saw your post!), so that is not an issue for us.
Comment #51
greg.1.anderson commentedOkay, I went ahead and published a release of the 2.x branch for you. You may now use drush dl drush_sup; you will get a message that says there are no releases (bug: Drush means there are no recommended releases, the cause of which is a d.o bug); at this point you may select 7.x-2.0-alpha1 to try out a release taken from the master branch.
Your comments in #49 are no doubt based on the 7.x-1.x-dev branch, which I cannot comment on save to say that it very rarely works correctly, and the errors you are encountering are probably due to these deficiencies. Try the 2.x branch; if you read the README closely and follow the instructions, it is likely to work well. If you have trouble with a specific module, try upgrading by hand, and if the problem persists, post a support request in the issue queue for the module in question, not here.
The problem I referred to with the token module produces an error message when Drush attempts to enable the module. I don't remember the specific message, but it has something to do with a cache table that does not exist in the database. Proceed as recommended above, and you shouldn't have any trouble.
Comment #52
Joel MMCC commentedThat worked nicely! Thanks much! I still have some theme work to do and some D6-only modules to find replacements for (or do without), but the site is working in D7 now!
Comment #53
greg.1.anderson commentedRe-running drush sup and re-using the same code as the last execution is working fairly well in 7.x-2.0-alpha2, so marking this 'fixed'.