diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-30 15:14:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-30 15:14:17 +0000 |
commit | 3fe9588b1c1c4fb58f8ba8e9c27244fc2fc1c103 (patch) | |
tree | d19448d010ff9d58fed14846736ee358fb6b3327 /db | |
parent | ad8eea383406037a207c80421e6e4bfa357f8044 (diff) | |
download | gitlab-ce-3fe9588b1c1c4fb58f8ba8e9c27244fc2fc1c103.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
6 files changed, 126 insertions, 0 deletions
diff --git a/db/migrate/20180902070406_create_group_group_links.rb b/db/migrate/20180902070406_create_group_group_links.rb new file mode 100644 index 00000000000..95fed0ebf96 --- /dev/null +++ b/db/migrate/20180902070406_create_group_group_links.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class CreateGroupGroupLinks < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + create_table :group_group_links do |t| + t.timestamps_with_timezone null: false + + t.references :shared_group, null: false, + index: false, + foreign_key: { on_delete: :cascade, + to_table: :namespaces } + t.references :shared_with_group, null: false, + foreign_key: { on_delete: :cascade, + to_table: :namespaces } + t.date :expires_at + t.index [:shared_group_id, :shared_with_group_id], + { unique: true, + name: 'index_group_group_links_on_shared_group_and_shared_with_group' } + t.integer :group_access, { limit: 2, + default: 30, # Gitlab::Access::DEVELOPER + null: false } + end + end + + def down + drop_table :group_group_links + end +end diff --git a/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb b/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb new file mode 100644 index 00000000000..86d581a4383 --- /dev/null +++ b/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddMarkForDeletionToProjects < ActiveRecord::Migration[5.2] + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + add_column :projects, :marked_for_deletion_at, :date + add_column :projects, :marked_for_deletion_by_user_id, :integer + end +end diff --git a/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb b/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb new file mode 100644 index 00000000000..d6ef6509fff --- /dev/null +++ b/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddMarkForDeletionIndexesToProjects < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :projects, :users, column: :marked_for_deletion_by_user_id, on_delete: :nullify + add_concurrent_index :projects, :marked_for_deletion_by_user_id, where: 'marked_for_deletion_by_user_id IS NOT NULL' + end + + def down + remove_foreign_key_if_exists :projects, column: :marked_for_deletion_by_user_id + remove_concurrent_index :projects, :marked_for_deletion_by_user_id + end +end diff --git a/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb b/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb new file mode 100644 index 00000000000..79546e33253 --- /dev/null +++ b/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddProjectDeletionAdjournedPeriodToApplicationSettings < ActiveRecord::Migration[5.2] + DOWNTIME = false + + DEFAULT_NUMBER_OF_DAYS_BEFORE_REMOVAL = 7 + + def change + add_column :application_settings, :deletion_adjourned_period, :integer, default: DEFAULT_NUMBER_OF_DAYS_BEFORE_REMOVAL, null: false + end +end diff --git a/db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb b/db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb new file mode 100644 index 00000000000..4e5b05ce363 --- /dev/null +++ b/db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb @@ -0,0 +1,35 @@ +# 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 ScheduleEpicIssuesAfterEpicsMove < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INTERVAL = 5.minutes.to_i + BATCH_SIZE = 100 + MIGRATION = 'MoveEpicIssuesAfterEpics' + + disable_ddl_transaction! + + class Epic < ActiveRecord::Base + self.table_name = 'epics' + + include ::EachBatch + end + + def up + return unless ::Gitlab.ee? + + Epic.each_batch(of: BATCH_SIZE) do |batch, index| + range = batch.pluck('MIN(id)', 'MAX(id)').first + delay = index * interval + BackgroundMigrationWorker.perform_in(delay, MIGRATION, *range) + end + end + + def down + # no need + end +end diff --git a/db/schema.rb b/db/schema.rb index c4a541824c8..df56b84d61b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -343,6 +343,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_124116) do t.string "custom_http_clone_url_root", limit: 511 t.boolean "pendo_enabled", default: false, null: false t.string "pendo_url", limit: 255 + t.integer "deletion_adjourned_period", default: 7, null: false t.index ["custom_project_templates_group_id"], name: "index_application_settings_on_custom_project_templates_group_id" t.index ["file_template_project_id"], name: "index_application_settings_on_file_template_project_id" t.index ["instance_administration_project_id"], name: "index_applicationsettings_on_instance_administration_project_id" @@ -1820,6 +1821,17 @@ ActiveRecord::Schema.define(version: 2019_10_26_124116) do t.index ["key", "value"], name: "index_group_custom_attributes_on_key_and_value" end + create_table "group_group_links", force: :cascade do |t| + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.bigint "shared_group_id", null: false + t.bigint "shared_with_group_id", null: false + t.date "expires_at" + t.integer "group_access", limit: 2, default: 30, null: false + t.index ["shared_group_id", "shared_with_group_id"], name: "index_group_group_links_on_shared_group_and_shared_with_group", unique: true + t.index ["shared_with_group_id"], name: "index_group_group_links_on_shared_with_group_id" + end + create_table "historical_data", id: :serial, force: :cascade do |t| t.date "date", null: false t.integer "active_user_count" @@ -3062,6 +3074,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_124116) do t.integer "max_artifacts_size" t.string "pull_mirror_branch_prefix", limit: 50 t.boolean "remove_source_branch_after_merge" + t.date "marked_for_deletion_at" + t.integer "marked_for_deletion_by_user_id" t.index "lower((name)::text)", name: "index_projects_on_lower_name" t.index ["archived", "pending_delete", "merge_requests_require_code_owner_approval"], name: "projects_requiring_code_owner_approval", where: "((pending_delete = false) AND (archived = false) AND (merge_requests_require_code_owner_approval = true))" t.index ["created_at"], name: "index_projects_on_created_at" @@ -3074,6 +3088,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_124116) do t.index ["last_repository_check_at"], name: "index_projects_on_last_repository_check_at", where: "(last_repository_check_at IS NOT NULL)" t.index ["last_repository_check_failed"], name: "index_projects_on_last_repository_check_failed" t.index ["last_repository_updated_at"], name: "index_projects_on_last_repository_updated_at" + t.index ["marked_for_deletion_by_user_id"], name: "index_projects_on_marked_for_deletion_by_user_id", where: "(marked_for_deletion_by_user_id IS NOT NULL)" t.index ["mirror_last_successful_update_at"], name: "index_projects_on_mirror_last_successful_update_at" t.index ["mirror_user_id"], name: "index_projects_on_mirror_user_id" t.index ["name"], name: "index_projects_on_name_trigram", opclass: :gin_trgm_ops, using: :gin @@ -4220,6 +4235,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_124116) do add_foreign_key "gpg_signatures", "projects", on_delete: :cascade add_foreign_key "grafana_integrations", "projects", on_delete: :cascade add_foreign_key "group_custom_attributes", "namespaces", column: "group_id", on_delete: :cascade + add_foreign_key "group_group_links", "namespaces", column: "shared_group_id", on_delete: :cascade + add_foreign_key "group_group_links", "namespaces", column: "shared_with_group_id", on_delete: :cascade add_foreign_key "identities", "saml_providers", name: "fk_aade90f0fc", on_delete: :cascade add_foreign_key "import_export_uploads", "projects", on_delete: :cascade add_foreign_key "index_statuses", "projects", name: "fk_74b2492545", on_delete: :cascade @@ -4343,6 +4360,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_124116) do add_foreign_key "project_statistics", "projects", on_delete: :cascade add_foreign_key "project_tracing_settings", "projects", on_delete: :cascade add_foreign_key "projects", "pool_repositories", name: "fk_6e5c14658a", on_delete: :nullify + add_foreign_key "projects", "users", column: "marked_for_deletion_by_user_id", name: "fk_25d8780d11", on_delete: :nullify add_foreign_key "prometheus_alert_events", "projects", on_delete: :cascade add_foreign_key "prometheus_alert_events", "prometheus_alerts", on_delete: :cascade add_foreign_key "prometheus_alerts", "environments", on_delete: :cascade |