aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-04-08 14:40:37 -0400
committerGitHub <noreply@github.com>2017-04-08 14:40:37 -0400
commitbb13c37fefdc8b5699918b38eff84751c2899ad5 (patch)
tree91ee33fece83403484db8bc06065380ceb2c8874 /activerecord/lib/active_record
parentf5d880866917724217eae9785a3ccd3f806c5aaf (diff)
parent826e49cfbe9589e600e652c31eb62954dcc86061 (diff)
downloadrails-bb13c37fefdc8b5699918b38eff84751c2899ad5.tar.gz
rails-bb13c37fefdc8b5699918b38eff84751c2899ad5.tar.bz2
rails-bb13c37fefdc8b5699918b38eff84751c2899ad5.zip
Merge pull request #28678 from hedgesky/use_formatted_number_as_schema_version
use formatted number as schema version
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index 2bbfd01698..657bd43b86 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -47,8 +47,16 @@ module ActiveRecord
@options = options
end
+ # turns 20170404131909 into "2017_04_04131909"
+ def formatted_version
+ return "" unless @version
+ stringified = @version.to_s
+ return stringified unless stringified.length == 14
+ stringified.insert(4, "_").insert(7, "_").insert(10, "_")
+ end
+
def header(stream)
- define_params = @version ? "version: #{@version}" : ""
+ define_params = @version ? "version: #{formatted_version}" : ""
stream.puts <<HEADER
# This file is auto-generated from the current state of the database. Instead