composite-primary-keys/composite_primary_keys

foreign_key and references in migrations does not work

Opened this issue · 1 comments

I would love to see support for foreign_key and references in migration to support composite keys.

such that the following will work:

def change
  create_table :tags do |t|
    t.string :user_first_name
    t.string :user_last_name

    t.foreign_key :user, column: [:first_name, :last_name], primary_key: [:user_first_name, :user_last_name]
  end
end

Similar for t.references

cfis commented

That would be a nice feature. Happy to take a patch if you would like to work on one.

Seems like work on composite primary keys is being done for ActiveRecord, hopefully that will include migration support.