Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-23 00:09:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-23 00:09:53 +0300
commitd6d1051383d42211e5f4d2752d60f946f21df1b7 (patch)
treee9f8a0c60c17ebc26a96e5349656d12d9aeb2a7f /db
parent0a5e00b6914944295b31ce10ffd5429cbe9fae89 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20191120115530_encrypt_plaintext_attributes_on_application_settings.rb16
-rw-r--r--db/migrate/20201008013434_generate_ci_jwt_signing_key.rb2
-rw-r--r--db/migrate/20210420012444_change_web_hook_events_default.rb15
-rw-r--r--db/migrate/20210420120734_initialize_conversion_of_ci_job_artifacts_to_bigint.rb22
-rw-r--r--db/post_migrate/20210420121149_backfill_conversion_of_ci_job_artifacts.rb29
-rw-r--r--db/schema_migrations/202104200124441
-rw-r--r--db/schema_migrations/202104201207341
-rw-r--r--db/schema_migrations/202104201211491
-rw-r--r--db/structure.sql14
9 files changed, 92 insertions, 9 deletions
diff --git a/db/migrate/20191120115530_encrypt_plaintext_attributes_on_application_settings.rb b/db/migrate/20191120115530_encrypt_plaintext_attributes_on_application_settings.rb
index e6b9a40ad4f..3ae5e3265e8 100644
--- a/db/migrate/20191120115530_encrypt_plaintext_attributes_on_application_settings.rb
+++ b/db/migrate/20191120115530_encrypt_plaintext_attributes_on_application_settings.rb
@@ -17,21 +17,21 @@ class EncryptPlaintextAttributesOnApplicationSettings < ActiveRecord::Migration[
class ApplicationSetting < ActiveRecord::Base
self.table_name = 'application_settings'
- def self.encryption_options_base_truncated_aes_256_gcm
+ def self.encryption_options_base_32_aes_256_gcm
{
mode: :per_attribute_iv,
- key: Gitlab::Application.secrets.db_key_base[0..31],
+ key: Gitlab::Utils.ensure_utf8_size(Rails.application.secrets.db_key_base, bytes: 32.bytes),
algorithm: 'aes-256-gcm',
encode: true
}
end
- attr_encrypted :akismet_api_key, encryption_options_base_truncated_aes_256_gcm
- attr_encrypted :elasticsearch_aws_secret_access_key, encryption_options_base_truncated_aes_256_gcm
- attr_encrypted :recaptcha_private_key, encryption_options_base_truncated_aes_256_gcm
- attr_encrypted :recaptcha_site_key, encryption_options_base_truncated_aes_256_gcm
- attr_encrypted :slack_app_secret, encryption_options_base_truncated_aes_256_gcm
- attr_encrypted :slack_app_verification_token, encryption_options_base_truncated_aes_256_gcm
+ attr_encrypted :akismet_api_key, encryption_options_base_32_aes_256_gcm
+ attr_encrypted :elasticsearch_aws_secret_access_key, encryption_options_base_32_aes_256_gcm
+ attr_encrypted :recaptcha_private_key, encryption_options_base_32_aes_256_gcm
+ attr_encrypted :recaptcha_site_key, encryption_options_base_32_aes_256_gcm
+ attr_encrypted :slack_app_secret, encryption_options_base_32_aes_256_gcm
+ attr_encrypted :slack_app_verification_token, encryption_options_base_32_aes_256_gcm
def akismet_api_key
decrypt(:akismet_api_key, self[:encrypted_akismet_api_key]) || self[:akismet_api_key]
diff --git a/db/migrate/20201008013434_generate_ci_jwt_signing_key.rb b/db/migrate/20201008013434_generate_ci_jwt_signing_key.rb
index 7983a56f439..5d7b6349fe6 100644
--- a/db/migrate/20201008013434_generate_ci_jwt_signing_key.rb
+++ b/db/migrate/20201008013434_generate_ci_jwt_signing_key.rb
@@ -8,7 +8,7 @@ class GenerateCiJwtSigningKey < ActiveRecord::Migration[6.0]
attr_encrypted :ci_jwt_signing_key, {
mode: :per_attribute_iv,
- key: Rails.application.secrets.db_key_base[0..31],
+ key: Gitlab::Utils.ensure_utf8_size(Rails.application.secrets.db_key_base, bytes: 32.bytes),
algorithm: 'aes-256-gcm',
encode: true
}
diff --git a/db/migrate/20210420012444_change_web_hook_events_default.rb b/db/migrate/20210420012444_change_web_hook_events_default.rb
new file mode 100644
index 00000000000..b5a63a5a2a8
--- /dev/null
+++ b/db/migrate/20210420012444_change_web_hook_events_default.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ChangeWebHookEventsDefault < ActiveRecord::Migration[6.0]
+ def up
+ change_column_default :web_hooks, :push_events, true
+ change_column_default :web_hooks, :issues_events, false
+ change_column_default :web_hooks, :merge_requests_events, false
+ change_column_default :web_hooks, :tag_push_events, false
+ end
+
+ # This is a NOP because this migration is supposed to restore the
+ # intended schema, not revert it.
+ def down
+ end
+end
diff --git a/db/migrate/20210420120734_initialize_conversion_of_ci_job_artifacts_to_bigint.rb b/db/migrate/20210420120734_initialize_conversion_of_ci_job_artifacts_to_bigint.rb
new file mode 100644
index 00000000000..715fe8b830a
--- /dev/null
+++ b/db/migrate/20210420120734_initialize_conversion_of_ci_job_artifacts_to_bigint.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class InitializeConversionOfCiJobArtifactsToBigint < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ TABLE = :ci_job_artifacts
+ COLUMNS = %i(id job_id)
+ TARGET_COLUMNS = COLUMNS.map { |col| "#{col}_convert_to_bigint" }
+
+ def up
+ initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
+ end
+
+ def down
+ trigger_name = rename_trigger_name(TABLE, COLUMNS, TARGET_COLUMNS)
+ remove_rename_triggers_for_postgresql TABLE, trigger_name
+
+ TARGET_COLUMNS.each do |column|
+ remove_column TABLE, column
+ end
+ end
+end
diff --git a/db/post_migrate/20210420121149_backfill_conversion_of_ci_job_artifacts.rb b/db/post_migrate/20210420121149_backfill_conversion_of_ci_job_artifacts.rb
new file mode 100644
index 00000000000..1fe1f9eed56
--- /dev/null
+++ b/db/post_migrate/20210420121149_backfill_conversion_of_ci_job_artifacts.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class BackfillConversionOfCiJobArtifacts < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ return unless should_run?
+
+ backfill_conversion_of_integer_to_bigint :ci_job_artifacts, %i(id job_id), batch_size: 15000, sub_batch_size: 100
+ end
+
+ def down
+ return unless should_run?
+
+ Gitlab::Database::BackgroundMigration::BatchedMigration
+ .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
+ .where(table_name: 'ci_job_artifacts', column_name: 'id')
+ .where('job_arguments = ?', [%w[id job_id], %w[id_convert_to_bigint job_id_convert_to_bigint]].to_json)
+ .delete_all
+ end
+
+ private
+
+ def should_run?
+ Gitlab.dev_or_test_env? || Gitlab.com?
+ end
+end
diff --git a/db/schema_migrations/20210420012444 b/db/schema_migrations/20210420012444
new file mode 100644
index 00000000000..5c098f44bc8
--- /dev/null
+++ b/db/schema_migrations/20210420012444
@@ -0,0 +1 @@
+f0bf8c79c1981ecd95c933f37ec5b0187ee6321792d96db26d863b192843c5ab \ No newline at end of file
diff --git a/db/schema_migrations/20210420120734 b/db/schema_migrations/20210420120734
new file mode 100644
index 00000000000..124fb5b28fe
--- /dev/null
+++ b/db/schema_migrations/20210420120734
@@ -0,0 +1 @@
+5404ecd22f943671c076b0e870a487ec822cb3d594c223ad4db5b1584394ceb6 \ No newline at end of file
diff --git a/db/schema_migrations/20210420121149 b/db/schema_migrations/20210420121149
new file mode 100644
index 00000000000..1326ed9a6f6
--- /dev/null
+++ b/db/schema_migrations/20210420121149
@@ -0,0 +1 @@
+58cd21a02a395564acf9abcc39c3daafc5db90aa0b3f29133644f21bb669cdf6 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 83394e38a80..90e69f4518c 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -115,6 +115,16 @@ BEGIN
END;
$$;
+CREATE FUNCTION trigger_be1804f21693() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+ NEW."id_convert_to_bigint" := NEW."id";
+ NEW."job_id_convert_to_bigint" := NEW."job_id";
+ RETURN NEW;
+END;
+$$;
+
CREATE TABLE audit_events (
id bigint NOT NULL,
author_id integer NOT NULL,
@@ -10572,6 +10582,8 @@ CREATE TABLE ci_job_artifacts (
file_sha256 bytea,
file_format smallint,
file_location smallint,
+ id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
+ job_id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL))
);
@@ -24664,6 +24676,8 @@ CREATE TRIGGER trigger_07c94931164e BEFORE INSERT OR UPDATE ON push_event_payloa
CREATE TRIGGER trigger_69523443cc10 BEFORE INSERT OR UPDATE ON events FOR EACH ROW EXECUTE PROCEDURE trigger_69523443cc10();
+CREATE TRIGGER trigger_be1804f21693 BEFORE INSERT OR UPDATE ON ci_job_artifacts FOR EACH ROW EXECUTE PROCEDURE trigger_be1804f21693();
+
CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON services FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_issue_tracker();
CREATE TRIGGER trigger_has_external_issue_tracker_on_insert AFTER INSERT ON services FOR EACH ROW WHEN ((((new.category)::text = 'issue_tracker'::text) AND (new.active = true) AND (new.project_id IS NOT NULL))) EXECUTE PROCEDURE set_has_external_issue_tracker();