Skip to content

Add relationship between project and project namespace

What does this MR do?

Adds a relationship between project and namespace via a new model ProjectNamespace.

DB migrations

up

== 20210824055322 AddProjectNamespaceIdToProject: migrating ===================
-- add_column(:projects, :project_namespace_id, :bigint)
   -> 0.0013s
== 20210824055322 AddProjectNamespaceIdToProject: migrated (0.0101s) ==========

== 20210824102624 AddProjectNamespaceIndexToProject: migrating ================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:projects, :project_namespace_id, {:name=>"index_projects_on_project_namespace_id", :unique=>true, :algorithm=>:concurrently})
   -> 0.0152s
-- execute("SET statement_timeout TO 0")
   -> 0.0004s
-- add_index(:projects, :project_namespace_id, {:name=>"index_projects_on_project_namespace_id", :unique=>true, :algorithm=>:concurrently})
   -> 0.0069s
-- execute("RESET statement_timeout")
   -> 0.0006s
== 20210824102624 AddProjectNamespaceIndexToProject: migrated (0.0295s) =======

== 20210824102750 AddProjectNamespaceForeignKeyToProject: migrating ===========
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:projects)
   -> 0.0029s
-- execute("ALTER TABLE projects\nADD CONSTRAINT fk_71625606ac\nFOREIGN KEY (project_namespace_id)\nREFERENCES namespaces (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0044s
-- execute("ALTER TABLE projects VALIDATE CONSTRAINT fk_71625606ac;")
   -> 0.0041s
== 20210824102750 AddProjectNamespaceForeignKeyToProject: migrated (0.0197s) ==

down

== 20210824102750 AddProjectNamespaceForeignKeyToProject: reverting ===========
-- foreign_keys(:projects)
   -> 0.0026s
-- remove_foreign_key(:projects, {:column=>:project_namespace_id})
   -> 0.0031s
== 20210824102750 AddProjectNamespaceForeignKeyToProject: reverted (0.0228s) ==

== 20210824102624 AddProjectNamespaceIndexToProject: reverting ================
-- transaction_open?()
   -> 0.0000s
-- indexes(:projects)
   -> 0.0127s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- remove_index(:projects, {:algorithm=>:concurrently, :name=>"index_projects_on_project_namespace_id"})
   -> 0.0016s
-- execute("RESET statement_timeout")
   -> 0.0005s
== 20210824102624 AddProjectNamespaceIndexToProject: reverted (0.0171s) =======

== 20210824055322 AddProjectNamespaceIdToProject: reverting ===================
-- remove_column(:projects, :project_namespace_id)
   -> 0.0008s
== 20210824055322 AddProjectNamespaceIdToProject: reverted (0.0036s) ==========

How to setup and validate locally (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #337099 (closed)

Edited by charlie ablett

Merge request reports