Wrong $saveMode parameter documentation in SchemaTool::updateSchema #4963

Closed
opened 2026-01-22 14:54:12 +01:00 by admin · 3 comments
Owner

Originally created by @dcb on GitHub (Jan 8, 2016).

Originally assigned to: @deeky666 on GitHub.

In Doctrine\ORM\Tools\SchemaTool::updateSchema the documentation states that "If $saveMode is set to true the command is executed in the Database, else SQL is returned.". That is wrong since the method never returns anything.
What actually happens when $saveMode is true is that the method calls toSaveSql instead of toSql in SchemaDiff which produces a non-destructive update. The details can be found in the documentation of Doctrine\DBAL\Schema\SchemaDiff::toSaveSql(). This is very useful, for example, when you want to do a partial update of the schema, you need $saveMode set to true otherwise updateSchema would drop all the tables not included in the update, learned that the hard way.

Originally created by @dcb on GitHub (Jan 8, 2016). Originally assigned to: @deeky666 on GitHub. In `Doctrine\ORM\Tools\SchemaTool::updateSchema` the documentation states that "If $saveMode is set to true the command is executed in the Database, else SQL is returned.". That is wrong since the method never returns anything. What actually happens when `$saveMode` is true is that the method calls `toSaveSql` instead of `toSql` in `SchemaDiff` which produces a non-destructive update. The details can be found in the documentation of `Doctrine\DBAL\Schema\SchemaDiff::toSaveSql()`. This is very useful, for example, when you want to do a partial update of the schema, you need `$saveMode` set to true otherwise `updateSchema` would drop all the tables not included in the update, learned that the hard way.
admin added the Documentation label 2026-01-22 14:54:12 +01:00
admin closed this issue 2026-01-22 14:54:12 +01:00
Author
Owner

@deeky666 commented on GitHub (Jan 8, 2016):

Yeah this seems to be a copy/paste issue from getUpdateSchemaSql()

@deeky666 commented on GitHub (Jan 8, 2016): Yeah this seems to be a copy/paste issue from `getUpdateSchemaSql()`
Author
Owner

@deeky666 commented on GitHub (Jan 8, 2016):

Noticing that also getUpdateSchemaSql() is wrong as is it oppositely states it will execute commands in DB eventually which is not true either.

@deeky666 commented on GitHub (Jan 8, 2016): Noticing that also `getUpdateSchemaSql()` is wrong as is it oppositely states it will execute commands in DB eventually which is not true either.
Author
Owner

@Ocramius commented on GitHub (Jan 8, 2016):

Done via #5597

@Ocramius commented on GitHub (Jan 8, 2016): Done via #5597
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4963