Friday, April 6, 2012

db table manipulation

Now I need to figure out how to fiddle with the layout of my database.  For testing sake, I'm going to try to add a field to my Users table in my database.

I think that I do this by modifying Entities.User.dcm.yml.  Simple enough, I'll just add some data:

    userName:
      type: string
      length: 255
      nullable: true
      column: user_name

Then I think that I just need to run a few CLI commands:
/usr/local/php53/bin/php doctrine-cli.php orm:generate-entities models 
/usr/local/php53/bin/php doctrine-cli.php orm:generate-proxies
/usr/local/php53/bin/php doctrine-cli.php orm:schema-tool:update



 Now lets see if it works, or if I just massively break it.

First two commands seem to work fine, on the schema update I get:


[yangon]$ /usr/local/php53/bin/php doctrine-cli.php orm:schema-tool:update
ATTENTION: This operation should not be executed in a production environment.
           Use the incremental update to detect changes during development and use
           the SQL DDL provided to manually update your database in production.
The Schema-Tool would execute "1" queries to update the database.
Please run the operation by passing one of the following options:
    orm:schema-tool:update --force to execute the command
    orm:schema-tool:update --dump-sql to dump the SQL statements to the screen

Lets try /usr/local/php53/bin/php doctrine-cli.php orm:schema-tool:update --dump-sql

Alright, that worked.  --dump-sql tells me what SQL statements it will execute, but it only shows me what it will do.  I had to do --force to execute the changes.  And they worked!


No comments:

Post a Comment