Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? :)

like image 781
Blankman Avatar asked Jul 29 '11 00:07

Blankman


2 Answers

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).

like image 165
GitNick Avatar answered Nov 15 '22 08:11

GitNick


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.

like image 36
davetapley Avatar answered Nov 15 '22 09:11

davetapley