aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema_dumper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/schema_dumper.rb')
-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