Rails: Best way to make changes to a production database

后端 未结 4 1529
滥情空心
滥情空心 2021-02-01 10:10

I need to make changes to an in-use production database. Just adding a few columns. I\'ve made the changes to the dev database with migrations. What is the best way to update

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 10:24

    Adding a column with add_column in a migration should be non-destructive: it will generate a "ALTER TABLE" statement. If you know what you're going to put into the columns once created, you can fill in the values within the migration (you may choose a less time-consuming alternative if the row counts are large).

    Removing or altering the definition of a column is, I think, platform-dependent: some will allow deletion of a column in place, others will perform a rename-create-select-drop sequence of commands.

    To get more specific, we need more information: what kind of migration are you looking at, what platform are you running on, do you need to set values as part of the migration? Stuff like that would help a lot - just edit the question, which will push it back up the list.

提交回复
热议问题