Getting CREATE SQL for single Doctrine entity in Symfony2

I needed to create a new table for a single new Doctrine entity into an existing database.

I was in hurry and couldn’t find a solution so came up with my own.

Dump the whole SQL into a file:

php app/console doctrine:schema:create --dump-sql > dump.sql

For fixing lowercase table name I found a solution at http://kurtfunai.com/2012/09/doctrine-table-name.html

/**
 * NAMESPACE\ExampleBundle\Entity\User
 *
 * @ORM\Entity
 * @ORM\Table(name="user")
 */
class User
{
Advertisements

About Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at https://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/
This entry was posted in php, Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s