8

I am building a complex application but i want to know that is it safe to use doctrine migrations in production.

For eg. the site has been used for 1 year and company wants to add extra attribute to user table.

So do i straight way chnage by going in database or through doctrine migrations

Mirage
  • 30,868
  • 62
  • 166
  • 261

2 Answers2

11

This is one of the intended uses (and benefits) of migrations - to automate the changes to your database quickly and accurately. Yes, they can and in most cases should be used to update your database in production.

Edit: The Symfony2 documentation also explains clearly this is one of the purposes of migrations.

Of course, the end goal of writing migrations is to be able to use them to reliably update your database structure when you deploy your application. By running the migrations locally (or on a beta server), you can ensure that the migrations work as you expect.

...

Community
  • 1
  • 1
deefour
  • 34,974
  • 7
  • 97
  • 90
  • 5
    Let me just add one thing: staging, ie., try it first on an exact clone of your live code and database first especially if you don't already use migrations regularly in your workflow. – MDrollette Jul 10 '12 at 04:43
1

Yes it would be safe.

I would just add an extra attribute in the User entity. Then run the doctrine:generate:entities command. That should generate the get/set methods. Then just update your database using doctrine:schema:update --force. That should add it into your database table.

Hyunmin Kim
  • 931
  • 2
  • 8
  • 18