Skip to content

Fix compound unique index for template in hierarchies_table #410

Open
@fkmy

Description

@fkmy

This is a proposal for the hierarchies_table template.
https://github.com/ClosureTree/closure_tree/blob/8550ddab5671a0d3b002e954796de44826585728/lib/generators/closure_tree/templates/create_hierarchies_table.rb.erb

I feel that the unique compound index of ancestor_id and descendant_id, is needed and generations is redundant.

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions