public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Added protection against duplicate migration names (Aslak Hellesøy) [#112 s
tate:resolved]
aslakhellesoy (author)
Tue May 06 22:59:34 -0700 2008
dhh (committer)
Sun May 11 11:37:29 -0700 2008
commit  10fdf44236ea9abfd327fc59d83670d4bcb3e0ca
tree    ca354edb2a0c16136304ba45a3f2b2462b68d0d7
parent  4cc594bd708df1ec67b61833493198ab0009c627
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Added protection against duplicate migration names (Aslak Hellesøy) [#112]
0
+
0
 * Base#instantiate_time_object: eliminate check for Time.zone, since we can assume this is set if time_zone_aware_attributes is set to true [Geoff Buesing]
0
 
0
 * Time zone aware attribute methods use Time.zone.parse instead of #to_time for String arguments, so that offset information in String is respected. Resolves #105. [Scott Fleckenstein, Geoff Buesing]
...
8
9
10
 
 
 
 
 
 
11
12
13
...
440
441
442
 
 
 
 
443
444
445
...
8
9
10
11
12
13
14
15
16
17
18
19
...
446
447
448
449
450
451
452
453
454
455
0
@@ -8,6 +8,12 @@ module ActiveRecord
0
     end
0
   end
0
 
0
+  class DuplicateMigrationNameError < ActiveRecordError#:nodoc:
0
+    def initialize(name)
0
+      super("Multiple migrations have the name #{name}")
0
+    end
0
+  end
0
+
0
   class UnknownMigrationVersionError < ActiveRecordError #:nodoc:
0
     def initialize(version)
0
       super("No migration with version number #{version}")
0
@@ -440,6 +446,10 @@ module ActiveRecord
0
           if klasses.detect { |m| m.version == version }
0
             raise DuplicateMigrationVersionError.new(version) 
0
           end
0
+
0
+          if klasses.detect { |m| m.name == name.camelize }
0
+            raise DuplicateMigrationNameError.new(name.camelize) 
0
+          end
0
           
0
           load(file)
0
           
...
984
985
986
 
 
 
 
 
 
987
988
989
...
984
985
986
987
988
989
990
991
992
993
994
995
0
@@ -984,6 +984,12 @@ if ActiveRecord::Base.connection.supports_migrations?
0
       end
0
     end
0
 
0
+    def test_migrator_with_duplicate_names
0
+      assert_raises(ActiveRecord::DuplicateMigrationNameError, "Multiple migrations have the name Chunky") do
0
+        ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate_names", nil)
0
+      end
0
+    end
0
+
0
     def test_migrator_with_missing_version_numbers
0
       assert_raise(ActiveRecord::UnknownMigrationVersionError) do
0
         ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/missing", 500)

Comments