Sha256: db39312f570aa50356403c2b7ec48a07ee44aa18cd5721a99ffe0a5a5cf8b468

Contents?: true

Size: 604 Bytes

Versions: 12

Compression:

Stored size: 604 Bytes

Contents

class AddOneRoleStrategy < ActiveRecord::Migration
  class << self

    def up          
      create_roles
      add_user_role
    end

    def down      
      drop_roles
      remove_user_role
    end

    protected

    def add_user_role
      change_table :users do |t|
        t.integer :role_id
      end
    end

    def remove_user_role
      change_table :users do |t|
        t.remove :role_id
      end
    end


    def create_roles
      create_table :roles do |t|
        t.string  :name
        t.timestamps
      end
    end

    def drop_roles
      drop_table :roles
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
roles_active_record-0.3.6 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.3.5 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.3.4 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.3.3 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.3.2 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.3.1 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.2.5 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.2.4 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.2.3 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.2.2 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.2.1 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb
roles_active_record-0.2.0 tmp/rails/db/migrations/20100912105323_add_one_role_strategy.rb