Skip to content

Add description field to organization

Abdul Wadood requested to merge 422078-add-organization-description into master

What does this MR do and why?

This is part of the ongoing Organization work by grouptenant scale. See the blueprint to learn more https://docs.gitlab.com/ee/architecture/blueprints/organization/index.html.

Create an organization_details table to store the organization description.

description_html and cached_markdown_version will be used by CacheMarkdownField for caching. The description and the related columns are not stored in the organizations table to avoid making it too wide which might have an impact on its performance in the future. We're doing the same with the namespaces table i.e. moving the description-related fields from the namespaces to thenamespace_details table. See Move description-related columns from namespace... (&7869).

All the fields and arguments introduced are experimental and therefore have been marked as alpha.

The GraphQL organization query and the organizationCreate mutation have been updated to return/accept the description.

Migration output

up
bin/rails db:migrate
main: == [advisory_lock_connection] object_id: 184060, pg_backend_pid: 84534
main: == 20231120090305 CreateOrganizationDetails: migrating ========================
main: -- create_table(:organization_details, {:id=>false})
main: -- quote_column_name(:description)
main:    -> 0.0000s
main:    -> 0.0151s
main: == 20231120090305 CreateOrganizationDetails: migrated (0.1132s) ===============

main: == [advisory_lock_connection] object_id: 184060, pg_backend_pid: 84534
ci: == [advisory_lock_connection] object_id: 184380, pg_backend_pid: 84536
ci: == 20231120090305 CreateOrganizationDetails: migrating ========================
ci: -- create_table(:organization_details, {:id=>false})
ci: -- quote_column_name(:description)
ci:    -> 0.0000s
ci:    -> 0.0155s
I, [2023-11-23T09:34:47.463246 #84350]  INFO -- : Database: 'ci', Table: 'organization_details': Lock Writes
ci: == 20231120090305 CreateOrganizationDetails: migrated (0.0292s) ===============

ci: == [advisory_lock_connection] object_id: 184380, pg_backend_pid: 84536
down
v=20231120090305
bin/rails db:migrate:down:ci VERSION=$v && bin/rails db:migrate:down:main VERSION=$v
ci: == [advisory_lock_connection] object_id: 183720, pg_backend_pid: 87213
ci: == 20231120090305 CreateOrganizationDetails: reverting ========================
ci: -- drop_table(:organization_details, {:id=>false})
ci:    -> 0.0039s
ci: == 20231120090305 CreateOrganizationDetails: reverted (0.0154s) ===============

ci: == [advisory_lock_connection] object_id: 183720, pg_backend_pid: 87213
main: == [advisory_lock_connection] object_id: 183760, pg_backend_pid: 87620
main: == 20231120090305 CreateOrganizationDetails: reverting ========================
main: -- drop_table(:organization_details, {:id=>false})
main:    -> 0.0024s
main: == 20231120090305 CreateOrganizationDetails: reverted (0.0065s) ===============

main: == [advisory_lock_connection] object_id: 183760, pg_backend_pid: 87620

How to set up and validate locally

Run the following query and mutation on GraphiQL https://gdk.test:3000/-/graphql-explorer:

Mutation

Input:

mutation {
  organizationCreate(
    input: {name: "GitLab", path: "gitlab-org", description: "GitLab Org"}
  ) {
    organization {
      id
      name
      path
      descriptionHtml
      description
    }
  }
}

Output:

{
  "data": {
    "organizationCreate": {
      "organization": {
        "id": "gid://gitlab/Organizations::Organization/1025",
        "name": "GitLab",
        "path": "gitlab-org",
        "descriptionHtml": "<p data-sourcepos=\"1:1-1:10\" dir=\"auto\">GitLab Org</p>",
        "description": "GitLab Org"
      }
    }
  }
}
Query

Input:

{
  organization(id: "gid://gitlab/Organizations::Organization/1025") {
    id
    name
    path
    description
    descriptionHtml
  }
}

Output:

{
  "data": {
    "organization": {
      "id": "gid://gitlab/Organizations::Organization/1025",
      "name": "GitLab",
      "path": "gitlab-org",
      "description": "GitLab Org",
      "descriptionHtml": "<p data-sourcepos=\"1:1-1:10\" dir=\"auto\">GitLab Org</p>"
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #422078 (closed)

Edited by Abdul Wadood

Merge request reports