Commit 1f79ef74 authored by pbair's avatar pbair

Allow test tables to use a specific gitlab schema

Update GitlabSchema to allow tables prefixed with _test_ to also specify
a schema they should use, rather than making them all :gitlab_shared.
parent 39f704cb
......@@ -78,7 +78,11 @@ module Gitlab
# All tables from `information_schema.` are `:gitlab_shared`
return :gitlab_shared if schema_name == 'information_schema'
# All tables that start with `_test_` are shared and ignored
return :gitlab_main if table_name.start_with?('_test_gitlab_main_')
return :gitlab_ci if table_name.start_with?('_test_gitlab_ci_')
# All tables that start with `_test_` without a following schema are shared and ignored
return :gitlab_shared if table_name.start_with?('_test_')
# All `pg_` tables are marked as `shared`
......
......@@ -44,6 +44,8 @@ RSpec.describe Gitlab::Database::GitlabSchema do
'my_schema.ci_builds' | :gitlab_ci
'information_schema.columns' | :gitlab_shared
'audit_events_part_5fc467ac26' | :gitlab_main
'_test_gitlab_main_table' | :gitlab_main
'_test_gitlab_ci_table' | :gitlab_ci
'_test_my_table' | :gitlab_shared
'pg_attribute' | :gitlab_shared
'my_other_table' | :undefined_my_other_table
......
......@@ -75,7 +75,7 @@ RSpec.describe AfterCommitQueue do
skip_if_multiple_databases_not_setup
table_sql = <<~SQL
CREATE TABLE _test_ci_after_commit_queue (
CREATE TABLE _test_gitlab_ci_after_commit_queue (
id serial NOT NULL PRIMARY KEY);
SQL
......@@ -84,7 +84,7 @@ RSpec.describe AfterCommitQueue do
let(:ci_klass) do
Class.new(Ci::ApplicationRecord) do
self.table_name = '_test_ci_after_commit_queue'
self.table_name = '_test_gitlab_ci_after_commit_queue'
include AfterCommitQueue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment