moosh icon indicating copy to clipboard operation
moosh copied to clipboard

Feature-request: Add sql-drop command

Open mikran opened this issue 5 years ago • 3 comments
trafficstars

Drush for Drupal has this, and it is useful when restoring db dumps. Command: moosh sql-drop -y && moosh sql-cli < myBackup.sql

mikran avatar Apr 03 '20 06:04 mikran

As an alternative, I think we could use "moosh sql-run" and (at least in MySQL) - the DATABASE() function: https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_database

tmuras avatar Apr 03 '20 06:04 tmuras

I'm not sure how that's an alternative. With sql-drop I'm looking to drop all tables from the database, not the whole database as that requires different kinds of permissions to do.

mikran avatar Apr 03 '20 06:04 mikran

I see. I usually prefer to DROP DATABASE and then CREATE DATABASE as that gives you 100% guarantee that everything was cleared (like functions, triggers). Maybe a better name (both here and in drush :) would be sql-drop-tables. Either way, it is a good idea - I'm marking that as a new feature and gladly accept a PR here!

tmuras avatar Apr 05 '20 15:04 tmuras