Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding documentation about composite FKs and how to simply add the

constraint
  • Loading branch information...
commit 89b9c714f5a20208fac89f85a1b3dde501ed8156 1 parent a1ae2a3
Rodrigo Kochenburger authored September 25, 2008 jeremyevans committed September 25, 2008

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. 7  lib/sequel_core/schema/generator.rb
7  lib/sequel_core/schema/generator.rb
@@ -200,6 +200,13 @@ def add_unique_constraint(columns, opts = {})
200 200
 
201 201
       # Add a foreign key with the given name and referencing the given table
202 202
       # to the DDL for the table.  See Generator#column for the available options.
  203
+      #
  204
+      # You can also pass an array of column names for creating composite foreign
  205
+      # keys. In this case, it will assume the columns exists and will only add
  206
+      # the constraint.
  207
+      #
  208
+      # NOTE: If you need to add a foreign key constraint to an existing column
  209
+      # use the composite key syntax even if it is only one column.
203 210
       def add_foreign_key(name, table, opts = {})
204 211
         return add_composite_foreign_key(name, table, opts) if name.is_a?(Array)
205 212
         add_column(name, :integer, {:table=>table}.merge(opts))

0 notes on commit 89b9c71

Please sign in to comment.
Something went wrong with that request. Please try again.