summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-01 22:59:17 -0700
committerStan Hu <stanhu@gmail.com>2019-06-01 23:06:46 -0700
commita52cbf6b00e65a52feb1ab0ff25c75858d39184a (patch)
tree5f49126ed5e7f6b91a4d921f8011066343b8657c
parent2ad5b30b6c02a3e3f84275121a709f5de75dac48 (diff)
downloadgitlab-ce-sh-fix-issue-58714.tar.gz
Fix migration failure when groups are missing routesh-fix-issue-58714
When a Group is missing a route, the migration failed previously with a `Invalid single-table inheritance type` error. To fix this, we can disable STI for the migration class because we don't need to know about the type to do this migration. Besides, currently Group is the only type used in the type column. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58714
-rw-r--r--changelogs/unreleased/sh-fix-issue-58714.yml5
-rw-r--r--db/migrate/20180702134423_generate_missing_routes.rb1
-rw-r--r--spec/migrations/generate_missing_routes_spec.rb2
3 files changed, 7 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-fix-issue-58714.yml b/changelogs/unreleased/sh-fix-issue-58714.yml
new file mode 100644
index 00000000000..597a011b6f3
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-issue-58714.yml
@@ -0,0 +1,5 @@
+---
+title: Fix migration failure when groups are missing route
+merge_request: 29022
+author:
+type: fixed
diff --git a/db/migrate/20180702134423_generate_missing_routes.rb b/db/migrate/20180702134423_generate_missing_routes.rb
index a440bc3179c..dd1106c9e6a 100644
--- a/db/migrate/20180702134423_generate_missing_routes.rb
+++ b/db/migrate/20180702134423_generate_missing_routes.rb
@@ -98,6 +98,7 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2]
class Namespace < ActiveRecord::Base
self.table_name = 'namespaces'
+ self.inheritance_column = :_type_disabled
include EachBatch
include GenerateMissingRoutes::Routable
diff --git a/spec/migrations/generate_missing_routes_spec.rb b/spec/migrations/generate_missing_routes_spec.rb
index 32515d353b0..30ad135d4df 100644
--- a/spec/migrations/generate_missing_routes_spec.rb
+++ b/spec/migrations/generate_missing_routes_spec.rb
@@ -8,7 +8,7 @@ describe GenerateMissingRoutes, :migration do
let(:routes) { table(:routes) }
it 'creates routes for projects without a route' do
- namespace = namespaces.create!(name: 'GitLab', path: 'gitlab')
+ namespace = namespaces.create!(name: 'GitLab', path: 'gitlab', type: 'Group')
routes.create!(
path: 'gitlab',