Skip to content
Browse files

Refactored how we verify db schema.

  • Loading branch information...
1 parent b182e7d commit ed52dd11a37f7b217d7819c1b7a124ce80d0667b Francesc Esplugas committed Feb 13, 2010
Showing with 6 additions and 6 deletions.
  1. +6 −6 app/controllers/typus_controller.rb
View
12 app/controllers/typus_controller.rb
@@ -126,17 +126,17 @@ def sign_up
private
- # TODO: Try to move schema verification to Typus.boot!
def verify_typus_users_table_schema
attributes = Typus.user_class.model_fields.keys
- generator = if !attributes.include?(:role) then "typus_update_schema_to_01"
- elsif !attributes.include?(:preferences) then "typus_update_schema_to_02"
- end
+ upgrades = ActiveSupport::OrderedHash.new
+ upgrades[:role] = "typus_update_schema_to_01"
+ upgrades[:preferences] = "typus_update_schema_to_02"
- if generator
- raise "Run `script/generate #{generator} -f && rake db:migrate` to update database schema."
+ upgrades.each do |key, value|
+ message = "Run `script/generate #{value} -f && rake db:migrate` to update database schema."
+ raise message if !attributes.include?(key)
end
end

0 comments on commit ed52dd1

Please sign in to comment.
Something went wrong with that request. Please try again.