create_table :user_roles do |t|
t.column :user_id, :bigint, :null => false
create_table :user_roles do |t|
t.column :user_id, :bigint, :null => false
User.where(:administrator => true).each do |user|
UserRole.create(:user_id => user.id, :role => "administrator")
end
User.where(:administrator => true).each do |user|
UserRole.create(:user_id => user.id, :role => "administrator")
end
- add_foreign_key :user_roles, [:user_id], :users, [:id]
+ add_foreign_key :user_roles, :users, :name => "user_roles_user_id_fkey"
end
def self.down
add_column :users, :administrator, :boolean, :default => false, :null => false
end
def self.down
add_column :users, :administrator, :boolean, :default => false, :null => false
UserRole.where(:role => "administrator").each do |role|
user = User.find(role.user_id)
user.administrator = true
user.save!
end
UserRole.where(:role => "administrator").each do |role|
user = User.find(role.user_id)
user.administrator = true
user.save!
end