29 Mar
duccio

duccio il 29 March 2007 parla di Rails Snippet

Sexy migration plugin

Un plug-in per semplificare la scrittura delle migrazioni compatibile al 100% con le vostre vecchie migrazioni.

si passa da così:

    1 class UpdateYourFamily < ActiveRecord::Migration
    2   create_table :updates do |t|
    3     t.column :user_id,  :integer
    4     t.column :group_id, :integer
    5     t.column :body,     :text
    6     t.column :type,     :string
    7 
    8     t.column :created_at, :datetime
    9     t.column :updated_at, :datetime 
   10   end
   11 
   12   def self.down
   13     drop_table :updates
   14   end
   15 end

a così:

    1 class UpdateYourFamily < ActiveRecord::Migration
    2   create_table :updates do
    3     foreign_key :user
    4     foreign_key :group
    5 
    6     text   :body
    7     string :type
    8 
    9     timestamps!
   10   end
   11 
   12   def self.down
   13     drop_table :updates
   14   end
   15 end

Come installarlo?

Come si è soliti fare per intallare un plug in:

    1 $ ./script/plugin install \ svn://errtheblog.com/svn/plugins/sexy_migrations

Grazie ai ragazzi di ErrtheBlog.

1 Commento a “Sexy migration plugin”

  1. Jonathan Métillon il 29 March 2007 alle 15:23 dice:

    Love it!

    Thanks Duccio.

Scrivi un commento