-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the Drush db-drop command #202
Comments
Hi @ElusiveMind - it would be good to document here a bit more about any potential use cases for this. It's obviously a dangerous command so if we did include this I think it would benefit from an "Are you sure?" prompt. Firstly, though, please could you explain the use case? I have used |
Hey @yorkshire-pudding - db-drop clears out all the tables. You can (most times) do a db-import to over-write tables, but depending on how the export happened, it may or may not delete and re-create the tables. A db-drop makes sure all the old data is removed before importing new data making sure all old-data is removed. |
Thanks @ElusiveMind - that's helpful I presume you've tested that bee will still work to import the replacement database? |
In keeping things in line with drush, I did not do a prompt nor export the database. I could add those, but would those be redundant since there are already bee commands to do that? A confirmation prompt, I agree, could be useful. Let me know how I should proceed. I would like to work toward getting this merged for some projects I am working on so I am happy to make changes. I just want to agree on those changes. Peace. |
@ElusiveMind - You're right about not duplicating export. Perhaps a confirmation yes or no? There are existing patterns for confirmation that allow the user to add a |
Thank you @ElusiveMind - I've done some testing and it seems to work well. There are a few improvements in the code review. Testing and reviewing this has helped to see how useful this function could be. I've suggested a reworded description to be more precise about the potential use case. |
I have made the requested changes. I also added one more. For db-export I was getting the semi-new mysql/mariadb error:
I added two new options: I tried to add this as '--extra-dump' with the arguments in quotes, but something wasn't working with that due to the way command line parsing was happening. That code is included for revision since it could be needed to do exports before running drops to test. |
@ElusiveMind
I don't think you need to accept a yes argument in the I agree that we'll need tests for db-drop that will need to be wrapped around with db-export and db-import but I tested these manually and there was no issue. We therefore need separate issue(s) for any feature requests and any bug reports so we can keep PRs focussed on one issue at a time. Thank you for your work on this; I do think this will be a valuable addition to bee. |
I've had to add one function for the dropping and creating of databases as per the new paradigm. I couldn't do this with the existing
This then allows me to call it (with confirm checking):
Would like to get thoughts before I push the change up for review. I have removed the secondary code also. |
@ElusiveMind In db-drop you know the commands being done and can decode the db name before inserting it in. What I'd like to see is
$options = '--user=' . rawurldecode($db_info['username']);
$options .= " --password='" . rawurldecode($db_info['password']) . "'";
$options .= ' --host=' . $db_info['host']; As Thanks |
@yorkshire-pudding - Thanks for all the feedback. I think i've done the implementation as suggested. My test indicate it is working also. Let me know how I can best serve |
@ElusiveMind - Hi Michael. I don't think we're too far off. There are a few bits of feedback on the PR. Are you happy to continue? If you're short on time at the moment but you'd like to pickup in the near future, let me know. Also, if for some reason you don't wish to continue, let me know and I'll look at getting it the rest of the way. Thanks for all your patience and work on this. |
Hey @yorkshire-pudding - I am happy to continue with this. I should have some more time after this weekend. I have a work deadline I need to make that is taking me 12-14 hours a day through at least Monday. Will that work? |
Hi @ElusiveMind - no problem - there's no rush, I just wanted to know your plans. |
I'm going to be revisiting this again as there have been quite a few changes to the way db commands work. Also, to note, in the #280 discussion, @indigoxela raised the point which is relevant to this feature that we shouldn't assume the user has both the DROP and CREATE permissions. I think we'll need to do something with |
@ElusiveMind - see my comments on the PR.
EDIT - See comment below - no need to do any checks for SHOW GRANTS.
|
Based on our findings (problems with drop/create will be rather an edge-case) I think, there's no need for an extra check for GRANTs. As far as I can see, the result is already evaluated (when dropping), so everything looks fine for me. (Note: I'll probably never need that command, as I prefer to use the mysql shell directly, when dropping and creating, so my opinion might not actually be relevant here.) |
Weren't the following commands: bee sql-drop
bee sql-dump
bee sql-cli introduced by commit on #129 |
Hi @alanmels But I can't see any PR with that commit (even though you reference a PR) and perhaps that's why it got overlooked. The later PR by @BWPanda does not have this in. I wasn't on the project then, but I am sorry that your contribution didn't get added. Thanks for your interest in bee - I hope you feel inspired to look at other tickets if you have time. |
I have created Pull request #201 to add the db-drop command to Bee. This also allows Bee to be bootstrapped with an empty database for the purposes of creating tables. I welcome comments and feedback as to the approach.
The text was updated successfully, but these errors were encountered: