diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-03-02 21:19:54 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-03-02 21:19:54 -0700 |
commit | 1a6c3f0a2ee9aaaa7b324f365a5a983f6178d8f9 (patch) | |
tree | e3b0f207683145845e05ca36fdd5b2d07d18de5c /activerecord/lib | |
parent | f32b6e243a1b84312bd72618454f79c9878beb19 (diff) | |
parent | d62b8f8dc01ddc45883e0a735075ba899c5aa34a (diff) | |
download | rails-1a6c3f0a2ee9aaaa7b324f365a5a983f6178d8f9.tar.gz rails-1a6c3f0a2ee9aaaa7b324f365a5a983f6178d8f9.tar.bz2 rails-1a6c3f0a2ee9aaaa7b324f365a5a983f6178d8f9.zip |
Merge pull request #19171 from JuanitoFatas/doc/more-examples
Add more documents for AR connection_adapters abstract schema_definitions. [ci skip]
Diffstat (limited to 'activerecord/lib')
-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 8231f44b4e..a768ee2d70 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 |