diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 00:09:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 00:09:07 +0000 |
commit | e144369009f3404072f7e0f969f7cded93195a01 (patch) | |
tree | d7a354e2c3c69a7ad65dc81aba8fe2ba59b0a26f /db | |
parent | d466ee5042520ad078fe050cb078d81dc2ebe196 (diff) | |
download | gitlab-ce-e144369009f3404072f7e0f969f7cded93195a01.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
6 files changed, 113 insertions, 0 deletions
diff --git a/db/migrate/20200131140428_create_index_on_auto_stop_in.rb b/db/migrate/20200131140428_create_index_on_auto_stop_in.rb new file mode 100644 index 00000000000..526e7dcfe30 --- /dev/null +++ b/db/migrate/20200131140428_create_index_on_auto_stop_in.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class CreateIndexOnAutoStopIn < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :environments, %i[state auto_stop_at], where: "auto_stop_at IS NOT NULL AND state = 'available'" + end + + def down + remove_concurrent_index :environments, %i[state auto_stop_at] + end +end diff --git a/db/migrate/20200209131152_add_feature_filter_type_to_user_preferences.rb b/db/migrate/20200209131152_add_feature_filter_type_to_user_preferences.rb new file mode 100644 index 00000000000..c05b624c438 --- /dev/null +++ b/db/migrate/20200209131152_add_feature_filter_type_to_user_preferences.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddFeatureFilterTypeToUserPreferences < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :user_preferences, :feature_filter_type, :bigint + end +end diff --git a/db/migrate/20200210184410_create_operations_strategies_table.rb b/db/migrate/20200210184410_create_operations_strategies_table.rb new file mode 100644 index 00000000000..1046bd11bc7 --- /dev/null +++ b/db/migrate/20200210184410_create_operations_strategies_table.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class CreateOperationsStrategiesTable < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + create_table :operations_strategies do |t| + t.references :feature_flag, index: true, null: false, foreign_key: { to_table: :operations_feature_flags, on_delete: :cascade } + t.string :name, null: false, limit: 255 + t.jsonb :parameters, null: false, default: {} + end + end +end diff --git a/db/migrate/20200210184420_create_operations_scopes_table.rb b/db/migrate/20200210184420_create_operations_scopes_table.rb new file mode 100644 index 00000000000..0b33882fe3d --- /dev/null +++ b/db/migrate/20200210184420_create_operations_scopes_table.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreateOperationsScopesTable < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + create_table :operations_scopes do |t| + t.references :strategy, null: false, index: false, foreign_key: { to_table: :operations_strategies, on_delete: :cascade } + t.string :environment_scope, null: false, limit: 255 + end + + add_index :operations_scopes, [:strategy_id, :environment_scope], unique: true + end +end diff --git a/db/post_migrate/20200210092405_save_instance_administrators_group_id.rb b/db/post_migrate/20200210092405_save_instance_administrators_group_id.rb new file mode 100644 index 00000000000..e539a187672 --- /dev/null +++ b/db/post_migrate/20200210092405_save_instance_administrators_group_id.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +class SaveInstanceAdministratorsGroupId < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + execute( + <<-SQL + UPDATE + application_settings + SET + instance_administrators_group_id = ( + SELECT + namespace_id + FROM + projects + WHERE + id = application_settings.instance_administration_project_id + ) + WHERE + instance_administrators_group_id IS NULL + AND + instance_administration_project_id IS NOT NULL + AND + ID in ( + SELECT + max(id) + FROM + application_settings + ) + SQL + ) + end + + def down + # no-op + + # The change performed by `up` cannot be reversed because once the migration runs, + # we do not know what value application_settings.instance_administrators_group_id + # had before the migration was run. + end +end diff --git a/db/schema.rb b/db/schema.rb index 2fd7341c4d9..fc30081cedf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1494,10 +1494,12 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do t.string "state", default: "available", null: false t.string "slug", null: false t.datetime_with_timezone "auto_stop_at" + t.index ["auto_stop_at"], name: "index_environments_on_auto_stop_at", where: "(auto_stop_at IS NOT NULL)" 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 t.index ["project_id", "state", "environment_type"], name: "index_environments_on_project_id_state_environment_type" + t.index ["state", "auto_stop_at"], name: "index_environments_on_state_and_auto_stop_at", where: "((auto_stop_at IS NOT NULL) AND ((state)::text = 'available'::text))" end create_table "epic_issues", id: :serial, force: :cascade do |t| @@ -2934,6 +2936,19 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do t.index ["project_id", "token_encrypted"], name: "index_feature_flags_clients_on_project_id_and_token_encrypted", unique: true end + create_table "operations_scopes", force: :cascade do |t| + t.bigint "strategy_id", null: false + t.string "environment_scope", limit: 255, null: false + t.index ["strategy_id", "environment_scope"], name: "index_operations_scopes_on_strategy_id_and_environment_scope", unique: true + end + + create_table "operations_strategies", force: :cascade do |t| + t.bigint "feature_flag_id", null: false + t.string "name", limit: 255, null: false + t.jsonb "parameters", default: {}, null: false + t.index ["feature_flag_id"], name: "index_operations_strategies_on_feature_flag_id" + end + create_table "packages_build_infos", force: :cascade do |t| t.integer "package_id", null: false t.integer "pipeline_id" @@ -4169,6 +4184,7 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do t.boolean "setup_for_company" t.boolean "render_whitespace_in_code" t.integer "tab_width", limit: 2 + t.bigint "feature_filter_type" t.index ["user_id"], name: "index_user_preferences_on_user_id", unique: true end @@ -4867,6 +4883,8 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do add_foreign_key "operations_feature_flag_scopes", "operations_feature_flags", column: "feature_flag_id", on_delete: :cascade add_foreign_key "operations_feature_flags", "projects", on_delete: :cascade add_foreign_key "operations_feature_flags_clients", "projects", on_delete: :cascade + add_foreign_key "operations_scopes", "operations_strategies", column: "strategy_id", on_delete: :cascade + add_foreign_key "operations_strategies", "operations_feature_flags", column: "feature_flag_id", on_delete: :cascade add_foreign_key "packages_build_infos", "ci_pipelines", column: "pipeline_id", on_delete: :nullify add_foreign_key "packages_build_infos", "packages_packages", column: "package_id", on_delete: :cascade add_foreign_key "packages_conan_file_metadata", "packages_package_files", column: "package_file_id", on_delete: :cascade |