Skip to content

Add "--dump-sql" option to "doctrine:fixtures:load" command #60

Closed
MacDada opened this Issue Sep 10, 2012 · 12 comments
@MacDada
MacDada commented Sep 10, 2012

It would work the same way as "doctrine:schema:create --dump-sql" by printing sql instead of applying it to the database.

@stof
Doctrine member
stof commented Sep 12, 2012

I don't think this is possible as doctrine:fixtures:load does not deal with SQL but works at the ORM level.

@wizardz
wizardz commented Apr 2, 2014

+1

@fdeleglise

Agree ;) ! +1

@luxifer
luxifer commented Apr 3, 2014

Why ? You could simple load your fixtures in the database and then dump the database to an sql file.

@AlexKovalevych

yes, we can do that, but would be nice to have that feature in fixtures, because sometimes you just need to see what its going to write into the database

@luxifer
luxifer commented Apr 3, 2014

As @stof said, the bundle deal with the ORM and not raw SQL, maybe something can be done before the flush, just sync the unit of work and instead of push it to the db, writing it down to stdout

@rafaelschmitt

+1

i am writing a deployment tool for deploying our software. the tool shouldn´t do all the db stuff on its own, we want to do this manually after the installation is complete. for this it would be nice when the fixtures command will dump the sqls like the schema:update command.

@jackcox
jackcox commented Sep 23, 2014

+1

@fazy
fazy commented Nov 27, 2014

+1

This might be difficult to implement, but if possible I would like it.

I'm trying to build an application to run in Docker. For the MySQL container, I want to be able to generate the SQL scripts for updating the schema and loading the fixtures. The SQL files can then be ADDed into the container and run at build time, so that a Docker image exists such as mycompany/myapp-mysql. When running a container based on that image, the schema and fixtures are already in place.

Apologies that the above is very Docker-specific. Another way to say it is, I want to be able to create the MySQL schema using a copy of the Symfony application, even if that application isn't connected to MySQL at the time.

It works for the schema:

php app/console doctrine:schema:create --dump-sql

(this command doesn't even notice if the DB doesn't exist, I get the SQL anyway)

There seems to be no equivalent with doctrine:fixtures:load. Probably if implemented, it will only work for simple code bases anyway - if your fixtures classes make reference to what they've already loaded, use last insert id etc, then I can't see how it can work.

So, "nice to have", but would be limited anyway.

For my use case above, I'll need to achieve this some other way. Any ideas?

@lavoiesl
Doctrine member

This would require a massive refactoring, possibly replacing the underlying connections by some dummy ones. It would also require to deal with corner cases around flushing/transactions. If this is really wanted, create an issue in https://github.com/doctrine/data-fixtures/ and will set the milestone to 2.0

@lavoiesl lavoiesl closed this Mar 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.