diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-10 07:53:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-10 07:53:40 +0000 |
commit | cfc792b9ca064990e6540cb742e80529ea669a81 (patch) | |
tree | 147cd4256319990cebbc02fe8e4fbbbe06f5720a /db | |
parent | 93c6764dacd4c605027ef1cd367d3aebe420b223 (diff) | |
download | gitlab-ce-cfc792b9ca064990e6540cb742e80529ea669a81.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
9 files changed, 179 insertions, 7 deletions
diff --git a/db/migrate/20191004151428_add_auto_stop_in_to_environments.rb b/db/migrate/20191004151428_add_auto_stop_in_to_environments.rb new file mode 100644 index 00000000000..860e52d420c --- /dev/null +++ b/db/migrate/20191004151428_add_auto_stop_in_to_environments.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddAutoStopInToEnvironments < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + add_column :environments, :auto_stop_at, :datetime_with_timezone + end +end diff --git a/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb b/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb new file mode 100644 index 00000000000..f172d3bdcbd --- /dev/null +++ b/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddExpireNotificationDeliveredToPersonalAccessTokens < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default :personal_access_tokens, :expire_notification_delivered, :boolean, default: false + end + + def down + remove_column :personal_access_tokens, :expire_notification_delivered + end +end diff --git a/db/migrate/20191121111621_create_packages_dependencies.rb b/db/migrate/20191121111621_create_packages_dependencies.rb new file mode 100644 index 00000000000..61e52627b05 --- /dev/null +++ b/db/migrate/20191121111621_create_packages_dependencies.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreatePackagesDependencies < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + create_table :packages_dependencies do |t| + t.string :name, null: false, limit: 255 + t.string :version_pattern, null: false, limit: 255 + end + + add_index :packages_dependencies, [:name, :version_pattern], unique: true + end +end diff --git a/db/migrate/20191121121947_create_packages_dependency_links.rb b/db/migrate/20191121121947_create_packages_dependency_links.rb new file mode 100644 index 00000000000..0907ed8f16c --- /dev/null +++ b/db/migrate/20191121121947_create_packages_dependency_links.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class CreatePackagesDependencyLinks < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + create_table :packages_dependency_links do |t| + t.references :package, index: false, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint + t.references :dependency, null: false, foreign_key: { to_table: :packages_dependencies, on_delete: :cascade }, type: :bigint + t.integer :dependency_type, limit: 2, null: false + end + + add_index :packages_dependency_links, [:package_id, :dependency_id, :dependency_type], unique: true, name: 'idx_pkgs_dep_links_on_pkg_id_dependency_id_dependency_type' + end +end diff --git a/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb b/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb new file mode 100644 index 00000000000..4511a2a0e49 --- /dev/null +++ b/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddProjectIdNameVersionPackageTypeIndexToPackagesPackages < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'idx_packages_packages_on_project_id_name_version_package_type'.freeze + + disable_ddl_transaction! + + def up + add_concurrent_index :packages_packages, + [:project_id, :name, :version, :package_type], + name: INDEX_NAME + end + + def down + remove_concurrent_index :packages_packages, + [:project_id, :name, :version, :package_type], + name: INDEX_NAME + end +end diff --git a/db/migrate/20191202181924_add_environment_auto_stop_in_to_ci_builds_metadata.rb b/db/migrate/20191202181924_add_environment_auto_stop_in_to_ci_builds_metadata.rb new file mode 100644 index 00000000000..bce191a7ec0 --- /dev/null +++ b/db/migrate/20191202181924_add_environment_auto_stop_in_to_ci_builds_metadata.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddEnvironmentAutoStopInToCiBuildsMetadata < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def up + add_column :ci_builds_metadata, :environment_auto_stop_in, :string, limit: 255 + end + + def down + remove_column :ci_builds_metadata, :environment_auto_stop_in + end +end diff --git a/db/post_migrate/20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb b/db/post_migrate/20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb new file mode 100644 index 00000000000..47622a216d9 --- /dev/null +++ b/db/post_migrate/20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +class MigrateOpsFeatureFlagsScopesTargetUserIds < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + class OperationsFeatureFlagScope < ActiveRecord::Base + include EachBatch + self.table_name = 'operations_feature_flag_scopes' + self.inheritance_column = :_type_disabled + end + + ### + # 2019-11-26 + # + # There are about 1000 rows in the operations_feature_flag_scopes table on gitlab.com. + # This migration will update about 30 of them. + # https://gitlab.com/gitlab-org/gitlab/merge_requests/20325#note_250742098 + # + # This should take a few seconds to run. + # https://gitlab.com/gitlab-org/gitlab/merge_requests/20325#note_254871603 + # + ### + def up + OperationsFeatureFlagScope.where("strategies @> ?", [{ 'name': 'userWithId' }].to_json).each_batch do |scopes| + scopes.each do |scope| + if scope.active + default_strategy = scope.strategies.find { |s| s['name'] == 'default' } + + if default_strategy.present? + scope.update({ strategies: [default_strategy] }) + end + else + user_with_id_strategy = scope.strategies.find { |s| s['name'] == 'userWithId' } + + scope.update({ + active: true, + strategies: [user_with_id_strategy] + }) + end + end + end + end + + def down + # This is not reversible. + # The old Target Users feature required the same list of user ids to be applied to each environment scope. + # Now we allow the list of user ids to differ for each scope. + end +end diff --git a/db/post_migrate/20191121122856_drop_packages_package_metadata_table.rb b/db/post_migrate/20191121122856_drop_packages_package_metadata_table.rb new file mode 100644 index 00000000000..9e24f64660c --- /dev/null +++ b/db/post_migrate/20191121122856_drop_packages_package_metadata_table.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class DropPackagesPackageMetadataTable < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def up + drop_table :packages_package_metadata + end + + def down + create_table :packages_package_metadata do |t| + t.references :package, index: { unique: true }, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :integer + t.binary :metadata, null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index bdc088820d4..b456159291d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -717,6 +717,7 @@ ActiveRecord::Schema.define(version: 2019_12_04_093410) do t.jsonb "config_options" t.jsonb "config_variables" t.boolean "has_exposed_artifacts" + t.string "environment_auto_stop_in", limit: 255 t.index ["build_id"], name: "index_ci_builds_metadata_on_build_id", unique: true t.index ["build_id"], name: "index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts", where: "(has_exposed_artifacts IS TRUE)" t.index ["build_id"], name: "index_ci_builds_metadata_on_build_id_and_interruptible", where: "(interruptible = true)" @@ -1447,6 +1448,7 @@ ActiveRecord::Schema.define(version: 2019_12_04_093410) do t.string "environment_type" t.string "state", default: "available", null: false t.string "slug", null: false + t.datetime_with_timezone "auto_stop_at" t.index ["name"], name: "index_environments_on_name_varchar_pattern_ops", opclass: :varchar_pattern_ops t.index ["project_id", "name"], name: "index_environments_on_project_id_and_name", unique: true t.index ["project_id", "slug"], name: "index_environments_on_project_id_and_slug", unique: true @@ -2822,6 +2824,20 @@ ActiveRecord::Schema.define(version: 2019_12_04_093410) do t.index ["package_id"], name: "index_packages_conan_metadata_on_package_id", unique: true end + create_table "packages_dependencies", force: :cascade do |t| + t.string "name", limit: 255, null: false + t.string "version_pattern", limit: 255, null: false + t.index ["name", "version_pattern"], name: "index_packages_dependencies_on_name_and_version_pattern", unique: true + end + + create_table "packages_dependency_links", force: :cascade do |t| + t.bigint "package_id", null: false + t.bigint "dependency_id", null: false + t.integer "dependency_type", limit: 2, null: false + t.index ["dependency_id"], name: "index_packages_dependency_links_on_dependency_id" + t.index ["package_id", "dependency_id", "dependency_type"], name: "idx_pkgs_dep_links_on_pkg_id_dependency_id_dependency_type", unique: true + end + create_table "packages_maven_metadata", force: :cascade do |t| t.bigint "package_id", null: false t.datetime_with_timezone "created_at", null: false @@ -2847,12 +2863,6 @@ ActiveRecord::Schema.define(version: 2019_12_04_093410) do t.index ["package_id", "file_name"], name: "index_packages_package_files_on_package_id_and_file_name" end - create_table "packages_package_metadata", force: :cascade do |t| - t.integer "package_id", null: false - t.binary "metadata", null: false - t.index ["package_id"], name: "index_packages_package_metadata_on_package_id", unique: true - end - create_table "packages_package_tags", force: :cascade do |t| t.integer "package_id", null: false t.string "name", limit: 255, null: false @@ -2867,6 +2877,7 @@ ActiveRecord::Schema.define(version: 2019_12_04_093410) do t.string "version" t.integer "package_type", limit: 2, null: false t.index ["name"], name: "index_packages_packages_on_name_trigram", opclass: :gin_trgm_ops, using: :gin + t.index ["project_id", "name", "version", "package_type"], name: "idx_packages_packages_on_project_id_name_version_package_type" t.index ["project_id"], name: "index_packages_packages_on_project_id" end @@ -2929,6 +2940,7 @@ ActiveRecord::Schema.define(version: 2019_12_04_093410) do t.string "scopes", default: "--- []\n", null: false t.boolean "impersonation", default: false, null: false t.string "token_digest" + t.boolean "expire_notification_delivered", default: false, null: false t.index ["token_digest"], name: "index_personal_access_tokens_on_token_digest", unique: true t.index ["user_id", "expires_at"], name: "index_pat_on_user_id_and_expires_at" t.index ["user_id"], name: "index_personal_access_tokens_on_user_id" @@ -4565,9 +4577,10 @@ ActiveRecord::Schema.define(version: 2019_12_04_093410) do add_foreign_key "operations_feature_flags_clients", "projects", on_delete: :cascade add_foreign_key "packages_conan_file_metadata", "packages_package_files", column: "package_file_id", on_delete: :cascade add_foreign_key "packages_conan_metadata", "packages_packages", column: "package_id", on_delete: :cascade + add_foreign_key "packages_dependency_links", "packages_dependencies", column: "dependency_id", on_delete: :cascade + add_foreign_key "packages_dependency_links", "packages_packages", column: "package_id", on_delete: :cascade add_foreign_key "packages_maven_metadata", "packages_packages", column: "package_id", name: "fk_be88aed360", on_delete: :cascade add_foreign_key "packages_package_files", "packages_packages", column: "package_id", name: "fk_86f0f182f8", on_delete: :cascade - add_foreign_key "packages_package_metadata", "packages_packages", column: "package_id", on_delete: :cascade add_foreign_key "packages_package_tags", "packages_packages", column: "package_id", on_delete: :cascade add_foreign_key "packages_packages", "projects", on_delete: :cascade add_foreign_key "pages_domain_acme_orders", "pages_domains", on_delete: :cascade |