aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorKonstantin Shabanov <etehtsea@gmail.com>2012-09-07 22:27:08 +0400
committerKonstantin Shabanov <etehtsea@gmail.com>2012-09-08 11:09:49 +0400
commitb485b8a06626be3a1b8a2037092a9dda1b28e8a4 (patch)
tree139444ad3ba8d37f2b28c3c8e66f5a97261cd0ef /activerecord/lib
parentf415475621c79cbc2d93e1ecf10805a4100a5d43 (diff)
downloadrails-b485b8a06626be3a1b8a2037092a9dda1b28e8a4.tar.gz
rails-b485b8a06626be3a1b8a2037092a9dda1b28e8a4.tar.bz2
rails-b485b8a06626be3a1b8a2037092a9dda1b28e8a4.zip
Dump schema using new style hash
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/schema.rb8
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb20
2 files changed, 14 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/schema.rb b/activerecord/lib/active_record/schema.rb
index a540bc0a3b..eaa4aa7086 100644
--- a/activerecord/lib/active_record/schema.rb
+++ b/activerecord/lib/active_record/schema.rb
@@ -11,16 +11,16 @@ module ActiveRecord
#
# ActiveRecord::Schema.define do
# create_table :authors do |t|
- # t.string :name, :null => false
+ # t.string :name, null: false
# end
#
# add_index :authors, :name, :unique
#
# create_table :posts do |t|
- # t.integer :author_id, :null => false
+ # t.integer :author_id, null: false
# t.string :subject
# t.text :body
- # t.boolean :private, :default => false
+ # t.boolean :private, default: false
# end
#
# add_index :posts, :author_id
@@ -50,7 +50,7 @@ module ActiveRecord
# The +info+ hash is optional, and if given is used to define metadata
# about the current schema (currently, only the schema's version):
#
- # ActiveRecord::Schema.define(:version => 20380119000001) do
+ # ActiveRecord::Schema.define(version: 20380119000001) do
# ...
# end
def self.define(info={}, &block)
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index a25a8d79bd..310b4c1459 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -38,7 +38,7 @@ module ActiveRecord
end
def header(stream)
- define_params = @version ? ":version => #{@version}" : ""
+ define_params = @version ? "version: #{@version}" : ""
if stream.respond_to?(:external_encoding) && stream.external_encoding
stream.puts "# encoding: #{stream.external_encoding.name}"
@@ -95,12 +95,12 @@ HEADER
tbl.print " create_table #{remove_prefix_and_suffix(table).inspect}"
if columns.detect { |c| c.name == pk }
if pk != 'id'
- tbl.print %Q(, :primary_key => "#{pk}")
+ tbl.print %Q(, primary_key: "#{pk}")
end
else
- tbl.print ", :id => false"
+ tbl.print ", id: false"
end
- tbl.print ", :force => true"
+ tbl.print ", force: true"
tbl.puts " do |t|"
# then dump all non-primary key columns
@@ -122,7 +122,7 @@ HEADER
spec[:scale] = column.scale.inspect if column.scale
spec[:null] = 'false' unless column.null
spec[:default] = default_string(column.default) if column.has_default?
- (spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.inspect} => ")}
+ (spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.to_s}: ")}
spec
end.compact
@@ -187,17 +187,17 @@ HEADER
statement_parts = [
('add_index ' + remove_prefix_and_suffix(index.table).inspect),
index.columns.inspect,
- (':name => ' + index.name.inspect),
+ ('name: ' + index.name.inspect),
]
- statement_parts << ':unique => true' if index.unique
+ statement_parts << 'unique: true' if index.unique
index_lengths = (index.lengths || []).compact
- statement_parts << (':length => ' + Hash[index.columns.zip(index.lengths)].inspect) unless index_lengths.empty?
+ statement_parts << ('length: ' + Hash[index.columns.zip(index.lengths)].inspect) unless index_lengths.empty?
index_orders = (index.orders || {})
- statement_parts << (':order => ' + index.orders.inspect) unless index_orders.empty?
+ statement_parts << ('order: ' + index.orders.inspect) unless index_orders.empty?
- statement_parts << (':where => ' + index.where.inspect) if index.where
+ statement_parts << ('where: ' + index.where.inspect) if index.where
' ' + statement_parts.join(', ')
end