[request] option to only use SQL in dumped schema information #5945

Closed
opened 2026-01-22 15:22:53 +01:00 by admin · 6 comments
Owner

Originally created by @holtkamp on GitHub (Apr 10, 2018).

Currently the dumped information of the UpdateCommand also includes non-SQL text:

"The following SQL statements will be executed:"

Is there a specific reason to do this? We currently store the output in a .sql file, which can then be easily executed, for example when spinning up a Docker instance. But the generated SQL is now "invalid" due to the help text.

Of course this text can be stripped after generation, but still, it feels awkward.

Originally created by @holtkamp on GitHub (Apr 10, 2018). Currently the dumped information of the [UpdateCommand](https://github.com/doctrine/doctrine2/blob/c4c59df1b4251f5030a08bd1253a0e472e4bdb7e/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php#L87) also includes non-SQL text: _"The following SQL statements will be executed:"_ Is there a specific reason to do this? We currently store the output in a .sql file, which can then be easily executed, for example when spinning up a Docker instance. But the generated SQL is now "invalid" due to the help text. Of course this text can be stripped after generation, but still, it feels awkward.
admin added the ImprovementQuestion labels 2026-01-22 15:22:53 +01:00
admin closed this issue 2026-01-22 15:22:53 +01:00
Author
Owner

@Ocramius commented on GitHub (Apr 10, 2018):

Good question, but a few problems arise:

  1. changing this may break existing hacks. I don't mind that much, but it can really introduce problems
  2. the dump command is, as it says, to dump information, not to generate an actually usable SQL string. For that, using the diffing tools directly would be more appropriate.
@Ocramius commented on GitHub (Apr 10, 2018): Good question, but a few problems arise: 1. changing this may break existing hacks. I don't mind that much, but it can really introduce problems 2. the `dump` command is, as it says, to `dump` information, not to generate an actually usable SQL string. For that, using the diffing tools directly would be more appropriate.
Author
Owner

@holtkamp commented on GitHub (Apr 10, 2018):

changing this may break existing hacks. I don't mind that much, but it can really introduce problems

True, also saw some commented "stripping" functionality in my scripts from the time when the warnings were printed in the beginning of the output, just re-activated /re-used that 😉

the dump command is, as it says, to dump information, not to generate an actually usable SQL string. For that, using the diffing tools directly would be more appropriate.

Also true. Maye a dedicated Command is required to write the output to a SQL file...

I kind of triggered when I saw this warning is not printed when being dumped / forced.

For now closing issue and stripping the first three lines from the outputted information.

@holtkamp commented on GitHub (Apr 10, 2018): > changing this may break existing hacks. I don't mind that much, but it can really introduce problems True, also saw some commented "stripping" functionality in my scripts from the time [when the warnings were printed](https://github.com/doctrine/doctrine2/blob/c4c59df1b4251f5030a08bd1253a0e472e4bdb7e/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php#L116-L119) in the beginning of the output, just re-activated /re-used that 😉 >the dump command is, as it says, to dump information, not to generate an actually usable SQL string. For that, using the diffing tools directly would be more appropriate. Also true. Maye a dedicated Command is required to write the output to a SQL file... I kind of triggered when I saw this warning is [not printed when being dumped / forced](https://github.com/doctrine/doctrine2/blob/c4c59df1b4251f5030a08bd1253a0e472e4bdb7e/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php#L110-L112). For now closing issue and stripping the first three lines from the outputted information.
Author
Owner

@Nek- commented on GitHub (Apr 10, 2018):

I think this feature may be discussed as it's interesting. Of course it's easy to use the SchemaTools to get the queries we want. But it could also be provided by default using some arguments or option to the command.

Maybe adding a "non-verbose" option is a good idea?

Suggestion for names:

  • --simple
  • --sql-only
  • --dump-only

Or in Doctrine3 it could be just change with adding a value to the dump arg. What do you think about?

It is a simple contribution that could be done at events like hacktoberfest fest.

@Nek- commented on GitHub (Apr 10, 2018): I think this feature may be discussed as it's interesting. Of course it's easy to use the `SchemaTools` to get the queries we want. But it could also be provided by default using some arguments or option to the command. Maybe adding a "non-verbose" option is a good idea? Suggestion for names: - `--simple` - `--sql-only` - `--dump-only` Or in Doctrine3 it could be just change with adding a value to the dump arg. What do you think about? It is a simple contribution that could be done at events like hacktoberfest fest.
Author
Owner

@holtkamp commented on GitHub (Apr 10, 2018):

Aah, I now see I referenced the UpdateCommand. That should be the CreateCommand 😊

I guess --sql-only would be my choice, since it seems semantically most correct:

./vendor/bin/doctrine orm:schema-tool:create --dump-sql --sql-only
@holtkamp commented on GitHub (Apr 10, 2018): Aah, I now see I referenced the UpdateCommand. That should be the [CreateCommand](https://github.com/doctrine/doctrine2/blob/967d34473e2d566d6f1beb3aca9a7da07f8fafe6/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php#L48) 😊 I guess `--sql-only` would be my choice, since it seems semantically most correct: ``` ./vendor/bin/doctrine orm:schema-tool:create --dump-sql --sql-only ```
Author
Owner

@Nek- commented on GitHub (Apr 10, 2018):

Both may be modifiy in this way. What do you think @Ocramius ?

@Nek- commented on GitHub (Apr 10, 2018): Both may be modifiy in this way. What do you think @Ocramius ?
Author
Owner

@Ocramius commented on GitHub (Apr 13, 2018):

Adding a flag that excludes all output and disables colors implicitly seems fine 👍

@Ocramius commented on GitHub (Apr 13, 2018): Adding a flag that excludes all output and disables colors implicitly seems fine :+1:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5945