From b2350f28dd3360975596fa5dfc9d436fa1082d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 20 Dec 2021 21:29:17 +0000 Subject: [PATCH] Revert "Merge pull request #43604 from nikonoid/bug/31722" This reverts commit 2374f0efedda67b316f980b0171320ba0171dd98, reversing changes made to b37c02e02730133ca85c8479d09b156be46c53d0. Since this break existing applications, and is necesary only because applications are not using timestamped migrations and are expecting it to just work, I decided to not revert this. Those application should either follow the timestamped migrations format or disable it. --- activerecord/lib/active_record/migration.rb | 2 +- activerecord/test/cases/migration_test.rb | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 14854f5a41..374ee2edf9 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -1001,7 +1001,7 @@ module ActiveRecord # Determines the version number of the next migration. def next_migration_number(number) if ActiveRecord.timestamped_migrations - [Time.now.utc.strftime("%Y%m%d%H%M%S").to_i, ("%.14d" % number).to_i].max + [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % number].max else SchemaMigration.normalize_migration_number(number) end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 7787179176..530f1f7833 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -148,15 +148,6 @@ class MigrationTest < ActiveRecord::TestCase assert_equal 20131219224947, migrator.current_version end - def test_migration_next_migration_number_consistent_across_year_boundary - last_year = Time.now.year - 1 - not_a_month = 14 - day_of_month = Time.now.day - time = Time.now.utc.strftime("%H%M%S") - last_year_number = "#{last_year}#{not_a_month}#{day_of_month}#{time}01" - assert_equal last_year_number, ActiveRecord::Migration.new.next_migration_number(last_year_number).to_s - end - def test_create_table_raises_if_already_exists connection = Person.connection connection.create_table :testings, force: true do |t|