Sha256: 082feb582ab07b966e55ac15079dd6cd53b50f31bcaa181354be839bdd2ad5e6
Contents?: true
Size: 737 Bytes
Versions: 2
Compression:
Stored size: 737 Bytes
Contents
class AddOneRoleStrategy < ActiveRecord::Migration def change create_roles add_user_role add_index :roles, :name, :unique => true # insert_roles end protected def add_user_role change_table :<%= table_name %> do |t| t.integer :role_id end end def remove_user_role change_table :<%= table_name %> do |t| t.remove :role_id end end def create_roles create_table :roles do |t| t.string :name, :null => false t.timestamps end end def drop_roles drop_table :roles end def insert_roles <%- roles_to_add.each do |role| -%> begin Role.create(:name => '<%= role %>') rescue end <%- end -%> end end
Version data entries
2 entries across 2 versions & 1 rubygems