zoukankan      html  css  js  c++  java
  • rails migrate specific version

    4.1 Rolling Back

    A common task is to rollback the last migration, for example if you made a mistake in it and wish to correct it. Rather than tracking down the version number associated with the previous migration you can run

    rake db:rollback

    This will run the down method from the latest migration. If you need to undo several migrations you can provide a STEP parameter:

    rake db:rollback STEP=3

    will run the down method from the last 3 migrations.

    The db:migrate:redo task is a shortcut for doing a rollback and then migrating back up again. As with the db:rollback task you can use the STEP parameter if you need to go more than one version back, for example

    rake db:migrate:redo STEP=3

    Neither of these Rake tasks do anything you could not do with db:migrate, they are simply more convenient since you do not need to explicitly specify the version to migrate to.

    Lastly, the db:reset task will drop the database, recreate it and load the current schema into it.

    This is not the same as running all the migrations – see the section on schema.rb.

    4.2 Being Specific

    If you need to run a specific migration up or down the db:migrate:up and db:migrate:down tasks will do that. Just specify the appropriate version and the corresponding migration will have its up or down method invoked, for example

    rake db:migrate:up VERSION=20080906120000

    will run the up method from the 20080906120000 migration. These tasks check whether the migration has already run, so for example db:migrate:up VERSION=20080906120000 will do nothing if Active Record believes that 20080906120000 has already been run.

  • 相关阅读:
    移植性问题のCString转char * ,string
    HDU 2894(欧拉回路)
    POJ 1149(最大流)
    POJ 3422 K取方格数(费用流)/TYVJ 1413
    POJ 1112(染色+连通分量+DP)
    POJ 2195(KM模板题)
    POJ 3615(FLOYD应用)
    POJ 1797(SPFA变种)spfa能做很多!
    POJ 1325(最小点覆盖)
    NOI2010 海拔(平面图最大流)
  • 原文地址:https://www.cnblogs.com/lexus/p/1903777.html
Copyright © 2011-2022 走看看