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

db:import | flag to not initialize Magento #890

Open
peterjaap opened this issue Jan 31, 2017 · 4 comments
Open

db:import | flag to not initialize Magento #890

peterjaap opened this issue Jan 31, 2017 · 4 comments

Comments

@peterjaap
Copy link

When setting up a new environment with an existing database dump, we want to use n98-magerun db:import to import the dump. But at that point, the database is empty so Magento cannot be initialized and the dump cannot be imported. A nice feature would be something like --no-initialize to just do an import, maybe querying database credentials from the user instead of reading them from the Magento configuration (or reading app/etc/local.xml beforehand).

@tkn98
Copy link
Collaborator

tkn98 commented Feb 10, 2017

I have problems to reproduce what you describe, for me it just works (see below for a log), I exported a dump, removed all tables from the database und imported the dump with db:import and I didn't need any special flag to make it working.

Please provide more details about the concrete problem you've been running into, e.g. the concrete command and it's output.

16:47 $ bin/n98-magerun db:dump dump.sql

                       
  Dump MySQL Database  
                       

Start dumping database magento_magerun_test to file dump.sql
Finished
✔ ~/PhpstormProjects/n98-magerun [develop|…2] 
16:47 $ bin/n98-magerun db:drop -tf
Dropped database tables 335 tables dropped
✔ ~/PhpstormProjects/n98-magerun [develop|…2] 
16:47 $ bin/n98-magerun db:drop -tf
Dropped database tables 0 tables dropped
✔ ~/PhpstormProjects/n98-magerun [develop|…2] 
16:47 $ bin/n98-magerun db:import dump.sql

                         
  Import MySQL Database  
                         

Importing SQL dump dump.sql to database magento_magerun_test
 718kB 0:00:07 [93.7kB/s] [===============================================================================================================================================================================================>] 100%            
Finished

@pocallaghan
Copy link
Contributor

@tkn98 during your test you're using the -f flag. This tells magerun to drop only the tables, not the actual database itself. If you connect with the mysql client (i.e. mysql -uuser -ppass) and run SHOW DATABASES you'll see it's still there. In the use-case that @peterjaap is describing, he's trying to import the DB from a completely cold start, i.e. without first having to issue a CREATE DATABASE foo query first.

@ktomk
Copy link
Collaborator

ktomk commented Feb 16, 2017

Ah, okay, well it would be convenient to create the db then as we can read the db name from the Magento configuration.

Also we could add a create database if not exists to the dump output, I think that is an option for mysqldump we use to create the dumps.

Perhaps both wouldn't hurt. However having the create database within the dump.sql file would tight the dump to the database name.

@tkn98
Copy link
Collaborator

tkn98 commented Feb 17, 2017

Just not it get's lost: When we provide parameters to override configuration database infos (host:port, db, credentials, socket etc.) we should consider having these parameters as well for the db:create and db:dump command. I like this idea, it's also a good change in time to switch away from camel-cased command-line parameters for the new ones (and perhaps deprecate the olders).

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

4 participants