add/drop FOREIGN KEY for existing table+column in Ecto migration

558 views
Skip to first unread message

Petrică Clement Chiriac

unread,
Sep 18, 2015, 2:58:39 PM9/18/15
to elixir-ecto
Hi,

we have a way to create FOREIGN KEY when add column.

But how to add this FOREIGN KEY/REFERENCES when
table and column already exists?

To drop and add FOREIGN KEY is util for import/export.

If no option here I can use direct DDL SQL

def up do
  execute """
   ALTER TABLE Orders ADD FOREIGN KEY (Persons_Id) REFERENCES Persons(Id)
  """
end

Thanks,
Petrica Clement Chiriac

Reply all
Reply to author
Forward
0 new messages