The usefulness of db migration rollback

Many people talk about db migration, especially the possibility of rollback.

I doubt how useful this is at all, because the db and model schema is closely related to application logic (MVC).

Suppose I rolled back some migration. So what? The application will not work, because its logic is completely dependent on db.

What are the rollback options for db migration?


Update 1

Main question

Why is rollback presented as a function when I need to change the code?

I do not create migrations, for example, add_another_field_to_table. Instead, each migration file fully describes each table in the database. When I need to change something in my database, I just modify the migration file, but it doesn’t roll it back .

, , , . , , .

+3
6

, DB. , , , . .

+8

Up?

  • .
  • , .
  • , .
  • , , , .

? , , , ( , , ), , . , .

...

  • ,
  • dev, scehma.rb
  • , DB, schema.rb .

....

  • . Rails , !

, , .

, 3 , ? , , ? 2 17 ? , , ? , ?

Rails ( ) , . .

+3

, , , .. . , , , , , , , - , :)

, , ( ) pull migrate.

+2

, . , . , , schema.rb . , , . , , , . , undefined. . , , 10 , . , , .

1

, , , . . , .

  • . (rake db:migrate VERSION=XXX, rake db:rollback STEP = 2, , 2 , STEP )
  • , . (rake db:migrate)

- , , schema.rb , . , , - . , . Rails , , user_id comment, , comment_instance.user_id. , .

+1

, capistrano . , , .

A git .

, , , , , .

0

rake db:migrate:redo .

0

All Articles