diff options
Diffstat (limited to 'db')
14 files changed, 149 insertions, 13 deletions
diff --git a/db/migrate/20170222111732_create_gpg_keys.rb b/db/migrate/20170222111732_create_gpg_keys.rb index 541228e8735..0d6d454bbf3 100644 --- a/db/migrate/20170222111732_create_gpg_keys.rb +++ b/db/migrate/20170222111732_create_gpg_keys.rb @@ -1,4 +1,6 @@ class CreateGpgKeys < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + DOWNTIME = false def change @@ -12,8 +14,8 @@ class CreateGpgKeys < ActiveRecord::Migration t.text :key - t.index :primary_keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil - t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil + t.index :primary_keyid, unique: true, length: mysql_compatible_index_length + t.index :fingerprint, unique: true, length: mysql_compatible_index_length end end end diff --git a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb index 55bf40ba24d..cc5cb355579 100644 --- a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb +++ b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb @@ -13,7 +13,7 @@ class AddForeignKeyPipelineSchedulesAndPipelines < ActiveRecord::Migration 'SET NULL' end - add_concurrent_foreign_key :ci_pipelines, :ci_pipeline_schedules, + add_concurrent_foreign_key :ci_pipelines, :ci_pipeline_schedules, column: :pipeline_schedule_id, on_delete: on_delete end diff --git a/db/migrate/20170613154149_create_gpg_signatures.rb b/db/migrate/20170613154149_create_gpg_signatures.rb index f6b5e7ebb7b..abef13a7a0b 100644 --- a/db/migrate/20170613154149_create_gpg_signatures.rb +++ b/db/migrate/20170613154149_create_gpg_signatures.rb @@ -1,4 +1,6 @@ class CreateGpgSignatures < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + DOWNTIME = false def change @@ -16,8 +18,8 @@ class CreateGpgSignatures < ActiveRecord::Migration t.text :gpg_key_user_name t.text :gpg_key_user_email - t.index :commit_sha, unique: true, length: Gitlab::Database.mysql? ? 20 : nil - t.index :gpg_key_primary_keyid, length: Gitlab::Database.mysql? ? 20 : nil + t.index :commit_sha, unique: true, length: mysql_compatible_index_length + t.index :gpg_key_primary_keyid, length: mysql_compatible_index_length end end end diff --git a/db/migrate/20170827123848_add_index_on_merge_request_diff_commit_sha.rb b/db/migrate/20170827123848_add_index_on_merge_request_diff_commit_sha.rb index 1b360b231a8..2140ff7b05e 100644 --- a/db/migrate/20170827123848_add_index_on_merge_request_diff_commit_sha.rb +++ b/db/migrate/20170827123848_add_index_on_merge_request_diff_commit_sha.rb @@ -8,7 +8,7 @@ class AddIndexOnMergeRequestDiffCommitSha < ActiveRecord::Migration disable_ddl_transaction! def up - add_concurrent_index :merge_request_diff_commits, :sha, length: Gitlab::Database.mysql? ? 20 : nil + add_concurrent_index :merge_request_diff_commits, :sha, length: mysql_compatible_index_length end def down diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb index c03c40416a8..d9dc2404cac 100644 --- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -1,4 +1,6 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + DOWNTIME = false def up @@ -8,8 +10,8 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration t.binary :keyid t.binary :fingerprint - t.index :keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil - t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil + t.index :keyid, unique: true, length: mysql_compatible_index_length + t.index :fingerprint, unique: true, length: mysql_compatible_index_length end add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify } diff --git a/db/migrate/20180910115836_add_attr_encrypted_columns_to_web_hook.rb b/db/migrate/20180910115836_add_attr_encrypted_columns_to_web_hook.rb new file mode 100644 index 00000000000..72f5c8d653b --- /dev/null +++ b/db/migrate/20180910115836_add_attr_encrypted_columns_to_web_hook.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddAttrEncryptedColumnsToWebHook < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :web_hooks, :encrypted_token, :string + add_column :web_hooks, :encrypted_token_iv, :string + + add_column :web_hooks, :encrypted_url, :string + add_column :web_hooks, :encrypted_url_iv, :string + end +end diff --git a/db/migrate/20180916011959_add_index_pipelines_project_id_source.rb b/db/migrate/20180916011959_add_index_pipelines_project_id_source.rb new file mode 100644 index 00000000000..b9bebf30cf0 --- /dev/null +++ b/db/migrate/20180916011959_add_index_pipelines_project_id_source.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIndexPipelinesProjectIdSource < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_pipelines, [:project_id, :source] + end + + def down + remove_concurrent_index :ci_pipelines, [:project_id, :source] + end +end diff --git a/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb b/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb new file mode 100644 index 00000000000..084dfc65ce5 --- /dev/null +++ b/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddDiffMaxPatchBytesToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default(:application_settings, + :diff_max_patch_bytes, + :integer, + default: 100.kilobytes, + allow_null: false) + end + + def down + remove_column(:application_settings, :diff_max_patch_bytes) + end +end diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb index 017c58477ac..08d7f499eec 100644 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb @@ -1,5 +1,3 @@ -require 'thread' - class RenameReservedProjectNames < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers include Gitlab::ShellAdapter diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb index 3e8ccfdb899..43a37667250 100644 --- a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb +++ b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb @@ -1,5 +1,3 @@ -require 'thread' - class RenameMoreReservedProjectNames < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers include Gitlab::ShellAdapter diff --git a/db/post_migrate/20180816193530_rename_login_root_namespaces.rb b/db/post_migrate/20180816193530_rename_login_root_namespaces.rb index b0c1fb98fa8..4ab1250473f 100644 --- a/db/post_migrate/20180816193530_rename_login_root_namespaces.rb +++ b/db/post_migrate/20180816193530_rename_login_root_namespaces.rb @@ -5,6 +5,8 @@ class RenameLoginRootNamespaces < ActiveRecord::Migration DOWNTIME = false + disable_ddl_transaction! + # We're taking over the /login namespace as part of a fix for the Jira integration def up disable_statement_timeout do diff --git a/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb b/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb new file mode 100644 index 00000000000..05ec4864a9e --- /dev/null +++ b/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class EncryptWebHooksColumns < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + BATCH_SIZE = 10000 + RANGE_SIZE = 100 + MIGRATION = 'EncryptColumns' + COLUMNS = [:token, :url] + + WebHook = ::Gitlab::BackgroundMigration::Models::EncryptColumns::WebHook + + disable_ddl_transaction! + + def up + WebHook.each_batch(of: BATCH_SIZE) do |relation, index| + delay = index * 2.minutes + + relation.each_batch(of: RANGE_SIZE) do |relation| + range = relation.pluck('MIN(id)', 'MAX(id)').first + args = [WebHook, COLUMNS, *range] + + BackgroundMigrationWorker.perform_in(delay, MIGRATION, args) + end + end + end + + def down + # noop + end +end diff --git a/db/post_migrate/20180916014356_populate_external_pipeline_source.rb b/db/post_migrate/20180916014356_populate_external_pipeline_source.rb new file mode 100644 index 00000000000..5577d05cf40 --- /dev/null +++ b/db/post_migrate/20180916014356_populate_external_pipeline_source.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class PopulateExternalPipelineSource < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + MIGRATION = 'PopulateExternalPipelineSource'.freeze + BATCH_SIZE = 500 + + disable_ddl_transaction! + + class Pipeline < ActiveRecord::Base + include EachBatch + self.table_name = 'ci_pipelines' + end + + def up + Pipeline.where(source: nil).tap do |relation| + queue_background_migration_jobs_by_range_at_intervals(relation, + MIGRATION, + 5.minutes, + batch_size: BATCH_SIZE) + end + end + + def down + # noop + end +end diff --git a/db/schema.rb b/db/schema.rb index f92d8005dfb..b3d4badaf82 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180917172041) do +ActiveRecord::Schema.define(version: 20180924141949) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -171,6 +171,7 @@ ActiveRecord::Schema.define(version: 20180917172041) do t.boolean "user_show_add_ssh_key_message", default: true, null: false t.integer "usage_stats_set_by_user_id" t.integer "receive_max_input_size" + t.integer "diff_max_patch_bytes", default: 102400, null: false end create_table "audit_events", force: :cascade do |t| @@ -475,6 +476,7 @@ ActiveRecord::Schema.define(version: 20180917172041) do add_index "ci_pipelines", ["project_id", "iid"], name: "index_ci_pipelines_on_project_id_and_iid", unique: true, where: "(iid IS NOT NULL)", using: :btree add_index "ci_pipelines", ["project_id", "ref", "status", "id"], name: "index_ci_pipelines_on_project_id_and_ref_and_status_and_id", using: :btree add_index "ci_pipelines", ["project_id", "sha"], name: "index_ci_pipelines_on_project_id_and_sha", using: :btree + add_index "ci_pipelines", ["project_id", "source"], name: "index_ci_pipelines_on_project_id_and_source", using: :btree add_index "ci_pipelines", ["project_id", "status", "config_source"], name: "index_ci_pipelines_on_project_id_and_status_and_config_source", using: :btree add_index "ci_pipelines", ["project_id"], name: "index_ci_pipelines_on_project_id", using: :btree add_index "ci_pipelines", ["status"], name: "index_ci_pipelines_on_status", using: :btree @@ -2271,6 +2273,10 @@ ActiveRecord::Schema.define(version: 20180917172041) do t.boolean "job_events", default: false, null: false t.boolean "confidential_note_events" t.text "push_events_branch_filter" + t.string "encrypted_token" + t.string "encrypted_token_iv" + t.string "encrypted_url" + t.string "encrypted_url_iv" end add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree |