Skip to content
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 db/drop-all-tables command #11288

Merged
merged 4 commits into from
Jun 6, 2022
Merged

Add db/drop-all-tables command #11288

merged 4 commits into from
Jun 6, 2022

Conversation

timkelty
Copy link
Contributor

@timkelty timkelty commented May 20, 2022

Description

Adds craft db/clean and a --clean flag to craft db/restore.

Includes a confirm dialog, and a big angry "this is destructive action" warning.

@timkelty timkelty requested a review from a team as a code owner May 20, 2022 17:17
@brandonkelly brandonkelly changed the base branch from develop to 4.1 June 6, 2022 13:19
@brandonkelly brandonkelly merged commit 13a3ed2 into 4.1 Jun 6, 2022
@brandonkelly brandonkelly deleted the feature/db-clean branch June 6, 2022 15:52
@brandonkelly brandonkelly changed the title Add db/clean command Add db/drop-all-tables command Jun 6, 2022
@jannisborgers
Copy link

Will this be available in Craft 3 at any chance? We’re on 3.7.43 right now and cannot upgrade to ^4 because of plugin compatibility.

When trying to use db/restore we get exit code 1: ERROR 1050 (42S01) at line 21: Table 'announcements' already exists and I cannot think of another solution than to drop all tables in the DB and restore after that.

Dropping the DB and creating a new one instead is an expensive option due to the client’s IT security (I cannot create a DB myself nor edit user privileges).

@brandonkelly
Copy link
Member

@jannisborgers No plans to, sorry.

It sounds like mysqldump wasn’t run with --add-drop-table, which would cause DROP TABLE statements to be included before each CREATE TABLE statement, which would avoid that error.

@jannisborgers
Copy link

@brandonkelly 😅 That was it! I exported it again with --add-drop-table checked (using TablePlus) and db/restore did its thing. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants