diff options
Diffstat (limited to 'db')
9 files changed, 139 insertions, 5 deletions
diff --git a/db/migrate/20200123040535_add_multi_column_index_on_lfs_objects_projects.rb b/db/migrate/20200123040535_add_multi_column_index_on_lfs_objects_projects.rb new file mode 100644 index 00000000000..36ccfa4743e --- /dev/null +++ b/db/migrate/20200123040535_add_multi_column_index_on_lfs_objects_projects.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddMultiColumnIndexOnLfsObjectsProjects < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :lfs_objects_projects, [:project_id, :lfs_object_id] + end + + def down + remove_concurrent_index :lfs_objects_projects, [:project_id, :lfs_object_id] + end +end diff --git a/db/migrate/20200123045415_remove_project_id_index_on_lfs_objects_projects.rb b/db/migrate/20200123045415_remove_project_id_index_on_lfs_objects_projects.rb new file mode 100644 index 00000000000..540383e8808 --- /dev/null +++ b/db/migrate/20200123045415_remove_project_id_index_on_lfs_objects_projects.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveProjectIdIndexOnLfsObjectsProjects < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + remove_concurrent_index :lfs_objects_projects, :project_id + end + + def down + add_concurrent_index :lfs_objects_projects, :project_id + end +end diff --git a/db/migrate/20200123092602_rename_services_template_to_instance.rb b/db/migrate/20200123092602_rename_services_template_to_instance.rb new file mode 100644 index 00000000000..42964dfe348 --- /dev/null +++ b/db/migrate/20200123092602_rename_services_template_to_instance.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RenameServicesTemplateToInstance < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + rename_column_concurrently :services, :template, :instance + end + + def down + undo_rename_column_concurrently :services, :template, :instance + end +end diff --git a/db/migrate/20200129234037_replace_conan_metadata_index.rb b/db/migrate/20200129234037_replace_conan_metadata_index.rb new file mode 100644 index 00000000000..4f55a2974d8 --- /dev/null +++ b/db/migrate/20200129234037_replace_conan_metadata_index.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class ReplaceConanMetadataIndex < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + OLD_INDEX = 'index_packages_conan_metadata_on_package_id' + NEW_INDEX = 'index_packages_conan_metadata_on_package_id_username_channel' + + disable_ddl_transaction! + + def up + add_concurrent_index :packages_conan_metadata, + [:package_id, :package_username, :package_channel], + unique: true, name: NEW_INDEX + + remove_concurrent_index_by_name :packages_conan_metadata, OLD_INDEX + end + + def down + add_concurrent_index :packages_conan_metadata, :package_id, name: OLD_INDEX + + remove_concurrent_index_by_name :packages_conan_metadata, NEW_INDEX + end +end diff --git a/db/post_migrate/20191021101942_remove_empty_github_service_templates.rb b/db/post_migrate/20191021101942_remove_empty_github_service_templates.rb index 64abe93b3e8..2f9db9e2cf6 100644 --- a/db/post_migrate/20191021101942_remove_empty_github_service_templates.rb +++ b/db/post_migrate/20191021101942_remove_empty_github_service_templates.rb @@ -23,6 +23,10 @@ class RemoveEmptyGithubServiceTemplates < ActiveRecord::Migration[5.2] private def relationship + # The column `template` was renamed to `instance`. Column information needs + # to be resetted to avoid cache problems after migrating down. + RemoveEmptyGithubServiceTemplates::Service.reset_column_information + RemoveEmptyGithubServiceTemplates::Service.where(template: true, type: 'GithubService') end end diff --git a/db/post_migrate/20200123101859_cleanup_rename_services_template_to_instance.rb b/db/post_migrate/20200123101859_cleanup_rename_services_template_to_instance.rb new file mode 100644 index 00000000000..904cad616d7 --- /dev/null +++ b/db/post_migrate/20200123101859_cleanup_rename_services_template_to_instance.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class CleanupRenameServicesTemplateToInstance < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + cleanup_concurrent_column_rename :services, :template, :instance + end + + def down + undo_cleanup_concurrent_column_rename :services, :template, :instance + end +end diff --git a/db/post_migrate/20200127111840_fix_projects_without_project_feature.rb b/db/post_migrate/20200127111840_fix_projects_without_project_feature.rb new file mode 100644 index 00000000000..66e892444d1 --- /dev/null +++ b/db/post_migrate/20200127111840_fix_projects_without_project_feature.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class FixProjectsWithoutProjectFeature < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + BATCH_SIZE = 50_000 + MIGRATION = 'FixProjectsWithoutProjectFeature' + + disable_ddl_transaction! + + class Project < ActiveRecord::Base + include EachBatch + end + + def up + queue_background_migration_jobs_by_range_at_intervals(Project, MIGRATION, 2.minutes, batch_size: BATCH_SIZE) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20200206111847_migrate_propagate_service_template_sidekiq_queue.rb b/db/post_migrate/20200206111847_migrate_propagate_service_template_sidekiq_queue.rb new file mode 100644 index 00000000000..30f6c2038d9 --- /dev/null +++ b/db/post_migrate/20200206111847_migrate_propagate_service_template_sidekiq_queue.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class MigratePropagateServiceTemplateSidekiqQueue < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + sidekiq_queue_migrate 'propagate_service_template', to: 'propagate_instance_level_service' + end + + def down + sidekiq_queue_migrate 'propagate_instance_level_service', to: 'propagate_service_template' + end +end diff --git a/db/schema.rb b/db/schema.rb index 35422461741..45fa6ca279c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_02_06_091544) do +ActiveRecord::Schema.define(version: 2020_02_06_111847) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -2347,7 +2347,7 @@ ActiveRecord::Schema.define(version: 2020_02_06_091544) do t.datetime "updated_at" t.integer "repository_type", limit: 2 t.index ["lfs_object_id"], name: "index_lfs_objects_projects_on_lfs_object_id" - t.index ["project_id"], name: "index_lfs_objects_projects_on_project_id" + t.index ["project_id", "lfs_object_id"], name: "index_lfs_objects_projects_on_project_id_and_lfs_object_id" end create_table "licenses", id: :serial, force: :cascade do |t| @@ -2945,7 +2945,7 @@ ActiveRecord::Schema.define(version: 2020_02_06_091544) do t.datetime_with_timezone "updated_at", null: false t.string "package_username", limit: 255, null: false t.string "package_channel", limit: 255, null: false - t.index ["package_id"], name: "index_packages_conan_metadata_on_package_id", unique: true + t.index ["package_id", "package_username", "package_channel"], name: "index_packages_conan_metadata_on_package_id_username_channel", unique: true end create_table "packages_dependencies", force: :cascade do |t| @@ -3827,7 +3827,6 @@ ActiveRecord::Schema.define(version: 2020_02_06_091544) do t.datetime "updated_at" t.boolean "active", default: false, null: false t.text "properties" - t.boolean "template", default: false t.boolean "push_events", default: true t.boolean "issues_events", default: true t.boolean "merge_requests_events", default: true @@ -3844,9 +3843,10 @@ ActiveRecord::Schema.define(version: 2020_02_06_091544) do t.boolean "deployment_events", default: false, null: false t.string "description", limit: 500 t.boolean "comment_on_event_enabled", default: true, null: false + t.boolean "instance", default: false + t.index ["instance"], name: "index_services_on_instance" t.index ["project_id"], name: "index_services_on_project_id" t.index ["project_id"], name: "tmp_index_on_project_id_partial_with_prometheus_services", where: "((type)::text = 'PrometheusService'::text)" - t.index ["template"], name: "index_services_on_template" t.index ["type"], name: "index_services_on_type" end |