Skip to content

Seed Default Organization in Production and Development

Rutger Wessels requested to merge rw-seed-default-organization into master

What does this MR do and why?

In !120118 (merged), we added the concept of a Default Organization. This organization was added using a database migration so gitlab.com does have this organization.

However, we also need to be sure that this organization is created on new installations. We do not run old migrations during the installation of a GitLab instance

This MR adds creation of the default organization to both development and production.

It also includes a migration that conditionally creates the Default Organization, for self-managed instances that were installed after the original migration.

Installed using GitLab version... Has the default organization? Solution
Before %16.0 Yes -
%16.0 No Will run migration from this MR
%16.1 and newer No Add Default Organization as part of DB seeding

Related issue #411441 (closed)

How to set up and validate locally

Rails Env Development:

  1. git checkout master
  2. gdk reset-data
  3. gdk psql -c "SELECT * FROM organizations WHERE id = 1" Result: no organizations
  4. git checkout rw-seed-default-organization
  5. gdk reset-data
  6. gdk psql -c "SELECT * FROM organizations WHERE id = 1" Result: one organization

Rails Env Production:

I ran this on my local development, while having redis listening on the default port:

  1. git checkout master
  2. DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=production rake db:environment:set db:drop db:create db:schema:load db:seed_fu
  3. gdk psql -c "SELECT * FROM organizations WHERE id = 1" Result: no organizations
  4. git checkout rw-seed-default-organization
  5. DISABLE_DATABASE_ENVIRONMENT_CHECK=1 RAILS_ENV=production rake db:environment:set db:drop db:create db:schema:load db:seed_fu
  6. gdk psql -c "SELECT * FROM organizations WHERE id = 1" Result: one organization

MR acceptance checklist

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

Edited by Rutger Wessels

Merge request reports