php bin/console doctrine:schema:update
Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.
Usage
doctrine:schema:update [--complete] [--dump-sql] [-f|--force] [--em [EM]]
Options
--complete If defined, all assets of the database which are not relevant to the current metadata will be dropped.
--dump-sql Dumps the generated SQL statements to the screen (does not execute them).
-f, --force Causes the generated SQL statements to be physically executed against your database.
--em The entity manager to use for this command
Help
The doctrine:schema:update command generates the SQL needed to
synchronize the database schema with the current mapping metadata of the
default entity manager.
For example, if you add metadata for a new column to an entity, this command
would generate and output the SQL needed to add the new column to the database:
doctrine:schema:update --dump-sql
Alternatively, you can execute the generated queries:
doctrine:schema:update --force
If both options are specified, the queries are output and then executed:
doctrine:schema:update --dump-sql --force
Finally, be aware that if the --complete option is passed, this
task will drop all database assets (e.g. tables, etc) that are *not* described
by the current metadata. In other words, without this option, this task leaves
untouched any "extra" tables that exist in the database, but which aren't
described by any metadata.
Hint: If you have a database with tables that should not be managed
by the ORM, you can use a DBAL functionality to filter the tables and sequences down
on a global level:
$config->setFilterSchemaAssetsExpression($regexp);