diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-24 09:09:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-24 09:09:43 +0000 |
commit | 028c7bdc315c3770f2ccc86f1100d90a5f702cad (patch) | |
tree | ee46807784d115a6bc4ffedbbd94588025e80b01 /lib | |
parent | d1727df7469dacdf782140d69e5cf3aa08d75ec9 (diff) | |
download | gitlab-ce-028c7bdc315c3770f2ccc86f1100d90a5f702cad.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/package_files.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/database/gitlab_schema.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/database/tables_locker.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/patch/database_config.rb | 18 | ||||
-rw-r--r-- | lib/tasks/gitlab/db.rake | 17 |
5 files changed, 31 insertions, 12 deletions
diff --git a/lib/api/package_files.rb b/lib/api/package_files.rb index bb9f96cdbb1..7ff49f326d9 100644 --- a/lib/api/package_files.rb +++ b/lib/api/package_files.rb @@ -29,6 +29,7 @@ module API params do use :pagination end + route_setting :authentication, job_token_allowed: true get ':id/packages/:package_id/package_files' do package = ::Packages::PackageFinder .new(user_project, params[:package_id]).execute @@ -51,6 +52,7 @@ module API params do requires :package_file_id, type: Integer, desc: 'ID of a package file' end + route_setting :authentication, job_token_allowed: true delete ':id/packages/:package_id/package_files/:package_file_id' do authorize_destroy_package!(user_project) diff --git a/lib/gitlab/database/gitlab_schema.rb b/lib/gitlab/database/gitlab_schema.rb index 926a4aeedf1..f11458945f4 100644 --- a/lib/gitlab/database/gitlab_schema.rb +++ b/lib/gitlab/database/gitlab_schema.rb @@ -23,6 +23,7 @@ module Gitlab tables.map { |table| table_schema(table, undefined: undefined) }.to_set end + # rubocop:disable Metrics/CyclomaticComplexity def self.table_schema(name, undefined: true) schema_name, table_name = name.split('.', 2) # Strip schema name like: `public.` @@ -57,6 +58,8 @@ module Gitlab return :gitlab_ci if table_name.start_with?('_test_gitlab_ci_') + return :gitlab_embedding if table_name.start_with?('_test_gitlab_embedding_') + return :gitlab_geo if table_name.start_with?('_test_gitlab_geo_') # All tables that start with `_test_` without a following schema are shared and ignored @@ -68,6 +71,7 @@ module Gitlab # When undefined it's best to return a unique name so that we don't incorrectly assume that 2 undefined schemas belong on the same database undefined ? :"undefined_#{table_name}" : nil end + # rubocop:enable Metrics/CyclomaticComplexity def self.dictionary_path_globs [Rails.root.join(DICTIONARY_PATH, '*.yml')] diff --git a/lib/gitlab/database/tables_locker.rb b/lib/gitlab/database/tables_locker.rb index 1b6ab3fb24b..0b0d46f4b0e 100644 --- a/lib/gitlab/database/tables_locker.rb +++ b/lib/gitlab/database/tables_locker.rb @@ -3,7 +3,7 @@ module Gitlab module Database class TablesLocker - GITLAB_SCHEMAS_TO_IGNORE = %i[gitlab_geo].freeze + GITLAB_SCHEMAS_TO_IGNORE = %i[gitlab_embedding gitlab_geo].freeze def initialize(logger: nil, dry_run: false) @logger = logger diff --git a/lib/gitlab/patch/database_config.rb b/lib/gitlab/patch/database_config.rb index 20d8f7be8fd..8a7566f6e0e 100644 --- a/lib/gitlab/patch/database_config.rb +++ b/lib/gitlab/patch/database_config.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # The purpose of this code is to set the migrations path -# for the Geo tracking database. +# for the Geo tracking database and the embedding database. module Gitlab module Patch module DatabaseConfig @@ -10,13 +10,17 @@ module Gitlab def database_configuration super.to_h do |env, configs| if Gitlab.ee? - if configs.key?("geo") - migrations_paths = Array(configs["geo"]["migrations_paths"]) - migrations_paths << "ee/db/geo/migrate" if migrations_paths.empty? - migrations_paths << "ee/db/geo/post_migrate" unless ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS'] + ee_databases = %w[embedding geo] - configs["geo"]["migrations_paths"] = migrations_paths.uniq - configs["geo"]["schema_migrations_path"] = "ee/db/geo/schema_migrations" if configs["geo"]["schema_migrations_path"].blank? + ee_databases.each do |ee_db_name| + next unless configs.key?(ee_db_name) + + migrations_paths = Array(configs[ee_db_name]['migrations_paths']) + migrations_paths << File.join('ee', 'db', ee_db_name, 'migrate') if migrations_paths.empty? + migrations_paths << File.join('ee', 'db', ee_db_name, 'post_migrate') unless ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS'] + + configs[ee_db_name]['migrations_paths'] = migrations_paths.uniq + configs[ee_db_name]['schema_migrations_path'] = File.join('ee', 'db', ee_db_name, 'schema_migrations') if configs[ee_db_name]['schema_migrations_path'].blank? end end diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 963fe23c682..7d95f744d44 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -4,6 +4,7 @@ databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml def each_database(databases, include_geo: false) ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |database| + next if database == 'embedding' next if !include_geo && database == 'geo' yield database @@ -472,15 +473,19 @@ namespace :gitlab do end namespace :dictionary do - DB_DOCS_PATH = File.join(Rails.root, 'db', 'docs') - EE_DICTIONARY_PATH = File.join(Rails.root, 'ee', 'db', 'docs') + DB_DOCS_PATH = Rails.root.join('db', 'docs') desc 'Generate database docs yaml' task generate: :environment do next if Gitlab.jh? FileUtils.mkdir_p(DB_DOCS_PATH) - FileUtils.mkdir_p(EE_DICTIONARY_PATH) if Gitlab.ee? + + if Gitlab.ee? + Gitlab::Database::EE_DATABASES_NAME_TO_DIR.each do |_, ee_db_dir| + FileUtils.mkdir_p(Rails.root.join(ee_db_dir, 'docs')) + end + end Rails.application.eager_load! @@ -558,7 +563,11 @@ namespace :gitlab do def dictionary_file_path(source_name, views, database) sub_directory = views.include?(source_name) ? 'views' : '' - path = database == 'geo' ? EE_DICTIONARY_PATH : DB_DOCS_PATH + path = if Gitlab.ee? && Gitlab::Database::EE_DATABASES_NAME_TO_DIR.key?(database.to_s) + Rails.root.join(Gitlab::Database::EE_DATABASES_NAME_TO_DIR[database.to_s], 'docs') + else + DB_DOCS_PATH + end File.join(path, sub_directory, "#{source_name}.yml") end |