aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/rails/generators
diff options
context:
space:
mode:
authorPhil Smith <phil.h.smith@gmail.com>2010-04-15 22:31:15 -0700
committerMichael Koziarski <michael@koziarski.com>2010-04-19 14:48:31 +1200
commit64373937a393518a6e6a63255176ca297d3c009e (patch)
tree13981412004257c9761e50a9f89e40a4e993e7a3 /activerecord/lib/rails/generators
parenteb83c9cf42aa208371643cdb10a2cbb8373e60ac (diff)
downloadrails-64373937a393518a6e6a63255176ca297d3c009e.tar.gz
rails-64373937a393518a6e6a63255176ca297d3c009e.tar.bz2
rails-64373937a393518a6e6a63255176ca297d3c009e.zip
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 <michael@koziarski.com>
Diffstat (limited to 'activerecord/lib/rails/generators')
-rw-r--r--activerecord/lib/rails/generators/active_record.rb5
1 files changed, 3 insertions, 2 deletions
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