diff options
author | Juanito Fatas <katehuang0320@gmail.com> | 2015-03-02 23:47:50 +0800 |
---|---|---|
committer | Juanito Fatas <katehuang0320@gmail.com> | 2015-03-03 09:28:54 +0800 |
commit | d62b8f8dc01ddc45883e0a735075ba899c5aa34a (patch) | |
tree | c5c40387bbaa0789c832d65faf6a5544b240b77f /activerecord | |
parent | 2675a57fc3071c49ba8276c50f29dde3d427bc7f (diff) | |
download | rails-d62b8f8dc01ddc45883e0a735075ba899c5aa34a.tar.gz rails-d62b8f8dc01ddc45883e0a735075ba899c5aa34a.tar.bz2 rails-d62b8f8dc01ddc45883e0a735075ba899c5aa34a.zip |
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?
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 16 |
1 files changed, 16 insertions, 0 deletions
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 |