1 class AddUniqueNameIndexToLinks < ActiveRecord::Migration
3 # Make sure PgPower is here. Otherwise the "where" will be ignored
4 # and we'll end up with a far too restrictive unique
5 # constraint. (Rails4 should work without PgPower, but that isn't
7 if not PgPower then raise "No partial column support" end
9 add_index(:links, [:tail_uuid, :name], unique: true,
10 where: "link_class='name'",
11 name: 'links_tail_name_unique_if_link_class_name')