Reputation: 9113
This might be a dumb question but I'm clueless as to how to go about this.
I've got the entity "MailEntity". However, My database does not contain a table that corresponds with this entity yet.
I would like to know how to generate the table that corresponds with the Entity I created. I've been looking for this but whatever I search on google, the same results seem to pop up constantly.
I've come to know that I can achieve what I want by doing php app/console doctrine:schema:update
. Adding the --dump-sql
parameter will dump the sql before the schema is actually updated.
However, I would like to do this for a single Bundle. A single Entity would be even better. I just want to create a table from the MailEntity
without changing anything else in the database.
Upvotes: 5
Views: 3997
Reputation: 1791
You could use php app/console doctrine:schema:update
.
This command will tell doctrine to execute the necessary SQL so that your database reflects your doctrine schema. Add --force
to actually execute the query.
If you want to check the generated SQL command first, you can use --dump-sql
. It will print what would be executed with --force
.
Related documentation you may read for further information
EDIT : If you want to create the table for a single entity, the easiest way is to dump the generated sql with --dump-sql
and then extract the line responsible of your MailEntity table creation, then execute it manually.
I would not recommend to do it this way though, you should let Doctrine synchronise your database on its own. This kind of tricks may result in errors in your database.
Upvotes: 1
Reputation: 76395
If you already have the entity classes ready to go, simply run:
app/console doctrine:schema:update
This should list all the queries doctrine needs to run to create the tables. Run the command with the --force
flag to execute them. It's documented here
It might be worth looking at the doctrine migrations bundle, which allows you to diff the current DB status with the entities, and generate migration scripts based on that diff see the docs
Upvotes: 6