From 64373937a393518a6e6a63255176ca297d3c009e Mon Sep 17 00:00:00 2001 From: Phil Smith Date: Thu, 15 Apr 2010 22:31:15 -0700 Subject: Make the migration generator handle pre-existing migrations with the same timestamp. In the event a migration already exists with that number, the new migration's timestamp will be incremented by 1. [#4412 state:resolved] Signed-off-by: Michael Koziarski --- activerecord/lib/rails/generators/active_record.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/rails/generators') diff --git a/activerecord/lib/rails/generators/active_record.rb b/activerecord/lib/rails/generators/active_record.rb index 1ca838b4f2..d2b1e86857 100644 --- a/activerecord/lib/rails/generators/active_record.rb +++ b/activerecord/lib/rails/generators/active_record.rb @@ -19,10 +19,11 @@ module ActiveRecord # Implement the required interface for Rails::Generators::Migration. # def self.next_migration_number(dirname) #:nodoc: + next_migration_number = current_migration_number(dirname) + 1 if ActiveRecord::Base.timestamped_migrations - Time.now.utc.strftime("%Y%m%d%H%M%S") + [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else - "%.3d" % (current_migration_number(dirname) + 1) + "%.3d" % next_migration_number end end end -- cgit v1.2.3