Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
495 views
in Technique[技术] by (71.8m points)

ruby - Editing Existing Rails Migrations is a good idea?

When starting out a new project, there are lot of changes in models that I find it easy to edit an existing migration & run db:clean or db:reset than create a new migration. I do this when app has not hit production which means I can reset/clean database without worries & I am working solo or part of a small team.

But Today, I came across the following advice in Rails Guide saying its not a good idea & discourages editing existing migrations:

Editing existing migrations is not a good idea: you will be creating extra work for yourself and your co-workers and cause major headaches if the existing version of the migration has already been run on production machines. Instead, you should write a new migration that performs the changes you require. Editing a freshly generated migration that has not yet been committed to source control (or, more generally, which has not been propagated beyond your development machine) is relatively harmless.

I want to know:

  • what potential pitfalls I can run into ?
  • Does those pitfalls apply in my case(development stage,working solo)?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you are working with a team and you committed the migration then NO.

If it is only on your local environment then just create a new migration fixing what you need. You can drop tablescolumns and do what you need.

Since you clean the db and reset it, then everyone will be doing the same or they will have issues if they try to migrate.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...