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_idandenvironment_scopetoclusterstable. So the migration code is going to beadd_index "clusters", ["project_id", "environment_scope"], unique: true, using: :btreeHowever,
clusterstable andprojecttable have Many-to-Many Relationship throughcluster_projectstable. Soclusterstable doesn't have FK forprojecttables (which meansproject_iddoesn't exist onclusterstable).Can I add the index in this case?