-1

What is the right way to use the functions in migration, 'up' and 'down'?

I required some new column names to be settled. So I had destroyed the old controller and generated a new one, and a new model with some columns.

Later on I had replaced 'change' function name with 'down', rake, it all goes normal.

But I'm still confused that why a 'down' works.

I assume the situation is because there were some column names conflicting, so migration task couldn't happen. Rails thinks migration was not rake, that's why it gave me pending migration error, and it loops. And 'down' function in migration will be forcibly ran, to solve some type issues or columns conflicting(mine situation).

is this what part of 'down' works for ?

davidrac
  • 10,723
  • 3
  • 39
  • 71
CoolDrinE
  • 11
  • 7

1 Answers1

0

down is used for reverting migrations rather than error handling (your situation).

ahmacleod
  • 4,280
  • 19
  • 43
X.Zeng
  • 1