From d62b8f8dc01ddc45883e0a735075ba899c5aa34a Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Mon, 2 Mar 2015 23:47:50 +0800 Subject: Add more documents for AR connection_adapters abstract schema_definitions. [ci skip] - Add example to column_exists? - Add example to index_exists? - Add document for foreign_key - Add document for foreign_key_exists? --- .../connection_adapters/abstract/schema_definitions.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'activerecord/lib/active_record/connection_adapters') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 0acc815d51..8c56ad12d8 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -535,6 +535,8 @@ module ActiveRecord # Checks to see if a column exists. # + # t.string(:name) unless t.column_exists?(:name, :string) + # # See SchemaStatements#column_exists? def column_exists?(column_name, type = nil, options = {}) @base.column_exists?(name, column_name, type, options) @@ -554,6 +556,10 @@ module ActiveRecord # Checks to see if an index exists. # + # unless t.index_exists?(:branch_id) + # t.index(:branch_id) + # end + # # See SchemaStatements#index_exists? def index_exists?(column_name, options = {}) @base.index_exists?(name, column_name, options) @@ -667,10 +673,20 @@ module ActiveRecord end alias :remove_belongs_to :remove_references + # Adds a foreign key. + # + # t.foreign_key(:authors) + # + # See SchemaStatements#add_foreign_key def foreign_key(*args) # :nodoc: @base.add_foreign_key(name, *args) end + # Checks to see if a foreign key exists. + # + # t.foreign_key(:authors) unless t.foreign_key_exists?(:authors) + # + # See SchemaStatements#foreign_key_exists? def foreign_key_exists?(*args) # :nodoc: @base.foreign_key_exists?(name, *args) end -- cgit v1.2.3