diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-10-17 21:35:19 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-10-17 21:35:19 +0000 |
commit | ac3cf4318294a798cf1e69ac17b93fe185109287 (patch) | |
tree | d77eaae77cbc24a70d158584d86e52b1018d1db0 | |
parent | 011a2091749f0b58a3233aeff5bfca67e5f7bfae (diff) | |
download | rails-ac3cf4318294a798cf1e69ac17b93fe185109287.tar.gz rails-ac3cf4318294a798cf1e69ac17b93fe185109287.tar.bz2 rails-ac3cf4318294a798cf1e69ac17b93fe185109287.zip |
Raise an intelligible error message when migration aren't named correctly [bronson] Closes #9909
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7957 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 4d099e057a..692859e2a6 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -8,6 +8,12 @@ module ActiveRecord end end + class IllegalMigrationNameError < ActiveRecordError#:nodoc: + def initialize(name) + super("Illegal name for migration file: #{name}\n\t(only lower case letters, numbers, and '_' allowed)") + end + end + # Migrations can manage the evolution of a schema used by several physical databases. It's a solution # to the common problem of adding a field to make a new feature work in your local database, but being unsure of how to # push that change to other developers and to the production server. With migrations, you can describe the transformations @@ -364,7 +370,9 @@ module ActiveRecord def migration_files files = Dir["#{@migrations_path}/[0-9]*_*.rb"].sort_by do |f| - migration_version_and_name(f).first.to_i + m = migration_version_and_name(f) + raise IllegalMigrationNameError.new(f) unless m + m.first.to_i end down? ? files.reverse : files end |