However, considering performance, I think it's necessary to define a new compound index for ancestor_id
, descendant_id
, and generations
.
add_index :<%= migration_name %>, [:ancestor_id, :descendant_id],
unique: true,
name: "<%= file_name %>_anc_desc_uniq_idx"
add_index :<%= migration_name %>, [:ancestor_id, :descendant_id, :generations],
name: "<%= file_name %>_anc_desc_gene_idx"