Posted by TravisCarden on January 8, 2010 at 7:53am
| Project: | Demonstration site (Sandbox / Snapshot) |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | sivaji |
| Status: | needs review |
| Issue tags: | drush |
Issue Summary
Are there any plans to add Drush support?
Comments
#1
I am currently working on this. I will submit a patch tomorrow.
#2
@sun I got the initial version of drush demo integration code done, please review it when you get time.
If anyone want to make improvement in the above patch, you would use this link http://api.drupalecommerce.org/api/drupal/contrib-6--drush--includes--dr...
#3
Thank you, @sivaji; this looks great! I've tested it with the latest dev release. Here are my findings/thoughts:
TOHAVE A BACKUP OF YOUR DATABASE". I've corrected them and attached a new patch.demo-create.) I don't know if it should be that way or not.demo-snapshotsshould sort the snapshots by date the way the web interface does?drush_confirmwhen deleting a snapshot.Thanks again, @sivaji! :)
#4
Oops. One more thing: It looks like if none of your snapshots have any description, it mucks up the table headings in the output of
demo-snapshots:Fi Da Si Desle te ze cri
na pti
me on
Fresh-Drupal-6.14-Install 11/28/2009 - 10:58 211.82 KB n/a
Tuned-Workspace 03/20/2010 - 12:44 228.22 KB n/a
Fresh-Drupal-6.15-Upgrade 02/23/2010 - 15:45 186.48 KB n/a
Fresh-Drupal-6.16-Upgrade 03/05/2010 - 18:19 198.57 KB n/a
If I simply add a snapshot with a description, I get this:
File name Date Size DescriptionTest 04/10/2010 - 17:47 228.42 KB This is an example test message
Fresh-Drupal-6.14-Install 11/28/2009 - 10:58 211.82 KB n/a
Tuned-Workspace 03/20/2010 - 12:44 228.22 KB n/a
Fresh-Drupal-6.15-Upgrade 02/23/2010 - 15:45 186.48 KB n/a
Fresh-Drupal-6.16-Upgrade 03/05/2010 - 18:19 198.57 KB n/a
#5
Also, could we shorten
demo-snapshotsto, say,demo-list? It's less to type, and I for one find it much easier to remember. (I have to stop and think every time to remember "snapshots".) If not, perhaps we could get a shorthand version of it.Speaking of which, perhaps we should add a command alias for
demo-delete, such asdemo-del, in keeping with the precedent set by Drush core (e.g.variable-delete (vdel)andwatchdog-delete (wd-del)).Finally, I wonder if there would be value in adding, say, a
demo-infocommand to get more detail on a particular snapshot (namely, a list of the modules installed, as you would find on the web interface) similar topm-infofor modules. Hopefully that's the last thought I'll have on this tonight. :)#6
Creating a snapshot through the web interface and through Drush resulted in backups of the same file size, which is goodI guess MD5 checksum is the ideal way to cross check this.
can execute the commands from Drush even if the module's not enabledThis is true (for instance see below), could be a bug in drush.
$ drush pm-list | grep -i demoDemonstration site (demo) Module Not installed
Demonstration site reset (demo_reset) Module Not installed
$ drush demo-snapshots
File name Date Size Description
snapshot-v1.0 2010-03-29 02:11 436.91 KB First version
simple_reservation 2010-04-05 23:22 484.54 KB simple_reservation module done
snapshot-Mon 2010-03-29 02:05 436.72 KB Mar
demo-snapshots should sort the snapshots by date the way the web interface doesDone, now it will list items sorted by modification date, recently modified file will appear first.
There should probably be a drush_confirm when deleting a snapshot.It makes sense. Added drush_confirm for delete command.
One more thing: It looks like if none of your snapshots have any description, it mucks up the table headings in the output of demo-snapshots:I can reproduce that only when the console width is small like 80x24 otherwise it looks fine. It is drush_print_table() API generating the table with dynamic width for columns. It turns too bad if i set width manually.
could we shorten demo-snapshotsto, say, demo-list?I like to go with following set of alias.
command alias
demo-create demo-mk
demo-delete demo-rm
demo-reset demo-rs
demo-snapshots demo-ss
demo-status demo-st
Let me know what you think about this.
#7
I compared the contents of a snapshot created through the web interface with those of one created with Drush, and they were identical except for a little session data, which is to be expected. So it looks like we're good on that front.
Your changes look great! I like how your first two command aliases (
demo-mkanddemo-rm) mirror corresponding Linux commands. That was smart. Unless the other three also mirror common commands I'm unfamiliar with (I'm a bit of a Linux n00b) I'd personally just omit them and suggestdemo-listas an alias fordemo-snapshots, but as you're the one doing all the work here, I happily defer to your judgment. :)I also proofread all the messages in the code and corrected a dozen or so typos and grammatical errors and made small changes to wording to maintain consistency with core Drush messages (mostly changing verb tenses). I also deleted a
TODOthat had been completed. Here's a new patch.#8
Uh-oh. Suddenly
demo-deleteisn't working for me, but I'm getting a PHP error instead of a Drush message:# drush demo-mk testSuccessfully created snapshot sites/all/files/demo/test.sql [ok]
# drush demo-rm test -y
This command will delete the snapshot and can not be undone [warning]
Are you sure you want to continue? (y/n): y
WD php: unlink(): No such file or directory in /home/bigfatug/public_html/test/sites/all/modules/contrib/demo/demo.drush.inc on line 178. [error]
WD php: unlink(): No such file or directory in /home/bigfatug/public_html/test/sites/all/modules/contrib/demo/demo.drush.inc on line 179. [error]
Deleted snapshot test [success]
Is it still working for you, @sivaji? I don't think I changed anything that should have broken it, but I don't have time to test further tonight.
#9
Thanks for correcting typos and grammars.
Aha that's my change in patch #6 breaking delete command, attached patch will fix that. I like to use
demo-ls(similar todemo-mkanddemo-rm) as an alias fordemo-snapshots. Let's see what others think and will choose the best one.Hopefully everything is working fine now, i am curious to hear from tha_sun (I remember i have to update #754798: Default dump file name will do later today.)
#10
Good thinking with
demo-ls; I like it.demo-deleteworks again.#11
I've been looking at
drush_print_tableanddrush_table_column_autowidthto see if I could identify the problem reported in comment #4 as belonging to Drush core, and I can't replicate the issue with any other commands. On the other hand, if I comment out line 197 of demo.drush.inc, I don't have the problem withdemo-snapshotsanymore, either.<?php// Line 197:
$rows[time()] = array('File name', 'Date', 'Size', 'Description');
?>
Does that suggest anything to you, @sivaji? I can't see what could be wrong with demo.drush.inc, but I can't seem to "break" anything else.
#12
Don't want to make this into a support request, but it might have relevance for this patch.
Does demo module have a concept of what is the "currently applied" demo snapshot?
If so, then a demo-update drush command to simply apply the current database state to the current applied snapshot would be helpful. Then again, perhaps this isn't such a good thing?
Here is my use case for reference. I'm using demo module to build a series of demo snapshots for a training course. The snapshots allow a student to "fast forward" to a specific point in the class (or catch up, etc.). What I'd like to be able to do is write a script using drush that will go through all the demo snapshots available, apply them, do a drush up to ensure they have the latest recommended versions of each module + update.php. That would be slightly simpler if a drush demo-update were possible so my script would use your drush demo-ls to get a list of the snapshots then looping through each one...
drush demo-reset "next one"
drush up
drush demo-update
loop
Anyway really glad drush integration is so close!
#13
I'm not entirely sure I understand the request, @winston. Your thought is that
demo-updatewould detect which snapshot the current state of the site reflected? In other words, it would compare your site with your snapshots and say, "This is the snapshot that your current site is based on". My first thought is that that isn't really feasible because the live database will have changed from the snapshot, even if only with respect to the sessions and logs. There are perhaps a few ways it could be basically accomplished, but those that I can think of would be either extremely complicated and resource-intensive or hacky. In short, it would involve the addition, not merely of a Drush interface, but a whole new feature to Demo module itself; for which reason I would encourage you, if you wish to pursue it, to open a separate feature request issue. As to your plan to create a script to loop through snapshots applying them, you should only need to apply the latest one, because each snapshot is a complete export of the database and stands alone. Applying several serially will have the exact same effect as just applying the last one. Best wishes!#14
Hey all. I'm interested in this support.
It seems to have stalled. How can I help move it forward from where it is currently at?
#15
@TravisCarden
Yes, you're right my request doesn't make any sense :/
However, I do think this functionality as discussed will be helpful for me as I should be able to do what I want with a regular shell script with this functionality available to Drush. Basically I'd like to be able to loop through a set of snapshots (which I would be able to get from list), apply them, do a drush up after the snapshot is applied, then create the snapshot again.
#16
@auzigog: Thanks for asking! You could test the patch in #9 and give your feedback. We've only had two eyes on it so far. Also, there's a bit of a rendering issue described in #4 and #11 that you could help us diagnose—or at least confirm it still exists. That would be a big help!
@winston: I still don't understand the need to loop through a set of snapshots, because snapshots aren't cumulative. Each one is a full database dump. If you apply one from yesterday,
drush up, and then apply one from today, whatever changes were made to the database viadrush upwill be overwritten and lost when you apply the second snapshot. You'll have todrush up. Just applying the very latest snapshot and doing adrush upwould have the same result (and, obviously, be much easier). If you still feel you need the functionality, please create a new support request. Thanks!#17
Subscribing.