Symfony + Doctrine: How to rebuild your DB
This post is about rebuilding your database from a schema.yml file in your Symfony project (Symfony version 1.4.8 embedded in the project at /path/to/your/project/lib/vendor/symfony/lib).
If you make a change in your config/doctrine/schema.yml, run these commands from your project’s root directory.
drop-db drops the database.
build-model creates the model from the schema file.
build-sql creates the SQL from the model.
create-db creates the database configured in config/databases.yml with the name of your project.
insert-sql inserts the SQL into the fresh database.
Note: You must drop your database in order to insert the generated SQL. The generated SQL does not include DROP TABLE or CREATE TABLE IF NOT EXISTS.
Note: These steps are for a development environment. If you run these commands you’ll lose all your data. If you have data you need saved. Make sure you run:
before dropping your database. This will store your data into a YAML file like data/fixtures/data.yml. After you’ve done the above steps, you can:
in order to reinsert the data into the database.