Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-07 03:08:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-07 03:08:25 +0300
commit3e31cffa203fd718381421e8035f7161a9f0338e (patch)
tree5d37928bebf08ddc931efe04a85d66217c8a0cea /db
parent1c25ac983cd1e4335faa1ec4922c314d6321e224 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb28
-rw-r--r--db/migrate/20200306170531_add_index_on_author_id_and_created_at_to_todos.rb16
-rw-r--r--db/post_migrate/20200227140242_update_occurrence_severity_column.rb34
-rw-r--r--db/schema.rb4
4 files changed, 63 insertions, 19 deletions
diff --git a/db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb b/db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb
index 4a05e2cd779..f04e0c68cf6 100644
--- a/db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb
+++ b/db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb
@@ -6,28 +6,20 @@ class InsertProjectSubscriptionsPlanLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
- return if Rails.env.test?
+ return unless Gitlab.com?
- if Gitlab.com?
- create_or_update_plan_limit('ci_project_subscriptions', 'free', 2)
- create_or_update_plan_limit('ci_project_subscriptions', 'bronze', 2)
- create_or_update_plan_limit('ci_project_subscriptions', 'silver', 2)
- create_or_update_plan_limit('ci_project_subscriptions', 'gold', 2)
- else
- create_or_update_plan_limit('ci_project_subscriptions', 'default', 2)
- end
+ create_or_update_plan_limit('ci_project_subscriptions', 'free', 2)
+ create_or_update_plan_limit('ci_project_subscriptions', 'bronze', 2)
+ create_or_update_plan_limit('ci_project_subscriptions', 'silver', 2)
+ create_or_update_plan_limit('ci_project_subscriptions', 'gold', 2)
end
def down
- return if Rails.env.test?
+ return unless Gitlab.com?
- if Gitlab.com?
- create_or_update_plan_limit('ci_project_subscriptions', 'free', 0)
- create_or_update_plan_limit('ci_project_subscriptions', 'bronze', 0)
- create_or_update_plan_limit('ci_project_subscriptions', 'silver', 0)
- create_or_update_plan_limit('ci_project_subscriptions', 'gold', 0)
- else
- create_or_update_plan_limit('ci_project_subscriptions', 'default', 0)
- end
+ create_or_update_plan_limit('ci_project_subscriptions', 'free', 0)
+ create_or_update_plan_limit('ci_project_subscriptions', 'bronze', 0)
+ create_or_update_plan_limit('ci_project_subscriptions', 'silver', 0)
+ create_or_update_plan_limit('ci_project_subscriptions', 'gold', 0)
end
end
diff --git a/db/migrate/20200306170531_add_index_on_author_id_and_created_at_to_todos.rb b/db/migrate/20200306170531_add_index_on_author_id_and_created_at_to_todos.rb
new file mode 100644
index 00000000000..d0d31ca7c52
--- /dev/null
+++ b/db/migrate/20200306170531_add_index_on_author_id_and_created_at_to_todos.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+class AddIndexOnAuthorIdAndCreatedAtToTodos < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :todos, [:author_id, :created_at]
+ end
+
+ def down
+ remove_concurrent_index :todos, [:author_id, :created_at]
+ end
+end
diff --git a/db/post_migrate/20200227140242_update_occurrence_severity_column.rb b/db/post_migrate/20200227140242_update_occurrence_severity_column.rb
new file mode 100644
index 00000000000..6d250532383
--- /dev/null
+++ b/db/post_migrate/20200227140242_update_occurrence_severity_column.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class UpdateOccurrenceSeverityColumn < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+ BATCH_SIZE = 1_000
+ INTERVAL = 5.minutes
+
+ # 23_044 records to be updated on GitLab.com,
+ def up
+ # create temporary index for undefined vulnerabilities
+ add_concurrent_index(:vulnerability_occurrences, :id, where: 'severity = 0', name: 'undefined_vulnerabilities')
+
+ return unless Gitlab.ee?
+
+ migration = Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceSeverityLevel
+ migration_name = migration.to_s.demodulize
+ relation = migration::Occurrence.undefined_severity
+ queue_background_migration_jobs_by_range_at_intervals(relation,
+ migration_name,
+ INTERVAL,
+ batch_size: BATCH_SIZE)
+ end
+
+ def down
+ # no-op
+ # temporary index is to be dropped in a different migration in an upcoming release
+ remove_concurrent_index(:vulnerability_occurrences, :id, where: 'severity = 0', name: 'undefined_vulnerabilities')
+ # This migration can not be reversed because we can not know which records had undefined severity
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 8cfa949548f..b49c68458ca 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_03_04_160823) do
+ActiveRecord::Schema.define(version: 2020_03_06_170531) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@@ -4150,6 +4150,7 @@ ActiveRecord::Schema.define(version: 2020_03_04_160823) do
t.integer "note_id"
t.string "commit_id"
t.integer "group_id"
+ t.index ["author_id", "created_at"], name: "index_todos_on_author_id_and_created_at"
t.index ["author_id"], name: "index_todos_on_author_id"
t.index ["commit_id"], name: "index_todos_on_commit_id"
t.index ["group_id"], name: "index_todos_on_group_id"
@@ -4540,6 +4541,7 @@ ActiveRecord::Schema.define(version: 2020_03_04_160823) do
t.string "metadata_version", null: false
t.text "raw_metadata", null: false
t.bigint "vulnerability_id"
+ t.index ["id"], name: "undefined_vulnerabilities", where: "(severity = 0)"
t.index ["primary_identifier_id"], name: "index_vulnerability_occurrences_on_primary_identifier_id"
t.index ["project_id", "primary_identifier_id", "location_fingerprint", "scanner_id"], name: "index_vulnerability_occurrences_on_unique_keys", unique: true
t.index ["scanner_id"], name: "index_vulnerability_occurrences_on_scanner_id"