Skip to content
Browse files

Adding documentation about composite FKs and how to simply add the

  • Loading branch information...
1 parent a1ae2a3 commit 89b9c714f5a20208fac89f85a1b3dde501ed8156 @divoxx divoxx committed with
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/sequel_core/schema/generator.rb
7 lib/sequel_core/schema/generator.rb
@@ -200,6 +200,13 @@ def add_unique_constraint(columns, opts = {})
# Add a foreign key with the given name and referencing the given table
# to the DDL for the table. See Generator#column for the available options.
+ #
+ # You can also pass an array of column names for creating composite foreign
+ # keys. In this case, it will assume the columns exists and will only add
+ # the constraint.
+ #
+ # NOTE: If you need to add a foreign key constraint to an existing column
+ # use the composite key syntax even if it is only one column.
def add_foreign_key(name, table, opts = {})
return add_composite_foreign_key(name, table, opts) if name.is_a?(Array)
add_column(name, :integer, {:table=>table}.merge(opts))

0 comments on commit 89b9c71

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