Add DB-level unique constraint to environment_scope in clusters table

The following discussion from gitlab-ce!15419 should be addressed:

  • @dosuken123 started a discussion: (+17 comments)

    @godfat I have a question.

    Cluster records are going to be looked up by environments, like environment specific secret variables.

    I'm thinking to add an index for project_id and environment_scope to clusters table. So the migration code is going to be

    add_index "clusters", ["project_id", "environment_scope"], unique: true, using: :btree

    However, clusters table and project table have Many-to-Many Relationship through cluster_projects table. So clusters table doesn't have FK for project tables (which means project_id doesn't exist on clusters table).

    Can I add the index in this case?

Assignee Loading
Time tracking Loading