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

Option to drop database before import #117

Open
synth opened this issue May 26, 2017 · 2 comments
Open

Option to drop database before import #117

synth opened this issue May 26, 2017 · 2 comments
Assignees
Milestone

Comments

@synth
Copy link

synth commented May 26, 2017

The import cmd (at least for mysql) is

mysql #{credentials} -D #{database} < #{file}

which will result in the file being appended to the current database.

Is there an option to drop the database before import? If not, can there be?

@numbata numbata self-assigned this Feb 27, 2018
@numbata numbata added this to the v0.7 milestone Feb 27, 2018
@numbata
Copy link
Collaborator

numbata commented Feb 27, 2018

Unfortunately, there isn't an option to drop database for mysql now.

But I think I can do it. "pgsql import" command already try to drop database before import.

Also I saw case where mysql user hasn't "create database" permissions. And we should be careful in "drop database" implementation.

@numbata numbata added the mysql label Feb 27, 2018
@kakra
Copy link

kakra commented Dec 9, 2019

I don't think it should ever drop the database - it's too dangerous. The DB may have unrelated table data outside of the Rails model scope. The pros and cons of such a setup may be discussed elsewhere but for historic reasons I am running such a database with one project. You can instruct mysqldump to add DROP TABLE IF EXISTS during export instead. It should be much more safe. Also, it may be better to wrap the export into one transaction, so on import it is either imported completely or aborted completely.

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

No branches or pull requests

3 participants