Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Ivor/815f9128fc73b162118dd6cdcc0b48e9 to your computer and use it in GitHub Desktop.
Save Ivor/815f9128fc73b162118dd6cdcc0b48e9 to your computer and use it in GitHub Desktop.
Ecto migration with unique_index on multiple fields.
defmodule VetMapper.Repo.Migrations.BranchesStreetAddressUniqueConstraint do
use Ecto.Migration
def up do
create unique_index(:branches, [:country, :state, :city, :street_name, :street_number], name: :index_branches_on_address)
end
def down do
drop index(:branches, [:country, :state, :city, :street_name, :street_number], name: :index_branches_on_address)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment