Add column rails migration

April 11, 2011 | By Regaz | Filed in: Uncategorized.

Here is a quick and clear tutorial about how to change a table adding one column:

  1. In your application’s root:

    $ rails generate migration add_column
  2. Open for editing your timestamp_add_column.rb with your favorite editor:

    $ sudo nano db/migration/timestamp_add_column.rb
  3. Edit you timestamp_add_column.rb:

    class AddColumn < ActiveRecord::Migration
    def self.up
    add_column :table_name, :column_name, :type

    def self.down
    remove_column :table_name, :column_name
  4. Execute your change by running the migration:

    $ rake db:migrate
  5. Do Not Forget to Take a Look…

    VMWare VMware, VMware Tools, VMware Tools

Tags: ,

QuickChic Theme • Powered by WordPress