Blankman
Blankman

Reputation: 266940

Rails.vim plugin, does it have any fancy migration support?

I am hoping rails.vim has some migration support.

I'm looking for something like: generate migration and jump to that file, and then a way to fire the migration.

Does this exist or am I dreaming? :)

Upvotes: 5

Views: 1211

Answers (3)

GitNick
GitNick

Reputation: 321

You definitely can!

As mentioned, you can run the following to generate a migration:

:Rgenerate migration migration_name ...

Then this will switch to the latest migration:

:Rmigration

And then finally:

:Rake db:migrate

will actually migrate it for you.

Also I shouldn't forget to add that running

:Rinvert

in a migration file, will try to create the down portion of your migration (or visa versa).

Upvotes: 13

davetapley
davetapley

Reputation: 17898

With regard to running a migration:

When in migration file, e.g. 123456789_my_migration.rb:

  • :Rake will call rake db:migrate VERSION=123456789.

    Note the . preceeding Rake in the following (this sends the line number to the command):

  • :.Rake on line 1, or inside the down method, will call
    rake db:migrate:down VERSION=123456789.

  • :.Rake on the last line, or inside the up method, will call
    rake db:migrate:up VERSION=123456789.

  • :.Rake anywhere else in the file will call
    rake db:migrate:down db:migrate:up VERSION=123456789.

I don't know of any documentation for this, I figured it out from looking at the appropriate part of rails.vim.

Upvotes: 3

e3matheus
e3matheus

Reputation: 2132

Jeje definitaly not dreaming. I should warn you that is a bit slow.

To generate the migration

:Rgenerate migration migration_name table_attributes

To run rake db:migrate

:Rake db:migrate

You can run an specific migration passing along VERSION="xxx". For more information on how to do this, you can go to :help rails-rake

Upvotes: 0

Related Questions