summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 11:28:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 11:28:26 +0000
commit7d5e6412bef7fd457e22532faf859e551f8196fc (patch)
treedc62b4a7a5fad8ba0ba260ae82e95f8e984f2398 /db
parent8e94dad32b10edebf79285c083176c2b7005ef64 (diff)
downloadgitlab-ce-7d5e6412bef7fd457e22532faf859e551f8196fc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200224185814_add_project_subscriptions_to_plan_limits.rb9
-rw-r--r--db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb33
-rw-r--r--db/migrate/20200228160542_create_ci_sources_projects.rb17
-rw-r--r--db/migrate/20200304121828_add_ci_sources_project_pipeline_foreign_key.rb13
-rw-r--r--db/migrate/20200304121844_add_ci_sources_project_source_project_foreign_key.rb13
-rw-r--r--db/schema.rb10
6 files changed, 95 insertions, 0 deletions
diff --git a/db/migrate/20200224185814_add_project_subscriptions_to_plan_limits.rb b/db/migrate/20200224185814_add_project_subscriptions_to_plan_limits.rb
new file mode 100644
index 00000000000..789f23501fb
--- /dev/null
+++ b/db/migrate/20200224185814_add_project_subscriptions_to_plan_limits.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProjectSubscriptionsToPlanLimits < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column(:plan_limits, :ci_project_subscriptions, :integer, default: 0, null: false)
+ end
+end
diff --git a/db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb b/db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb
new file mode 100644
index 00000000000..4a05e2cd779
--- /dev/null
+++ b/db/migrate/20200225123228_insert_project_subscriptions_plan_limits.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class InsertProjectSubscriptionsPlanLimits < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ return if Rails.env.test?
+
+ 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
+ end
+
+ def down
+ return if Rails.env.test?
+
+ 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
+ end
+end
diff --git a/db/migrate/20200228160542_create_ci_sources_projects.rb b/db/migrate/20200228160542_create_ci_sources_projects.rb
new file mode 100644
index 00000000000..36f5167a784
--- /dev/null
+++ b/db/migrate/20200228160542_create_ci_sources_projects.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateCiSourcesProjects < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :ci_sources_projects do |t|
+ t.bigint :pipeline_id, null: false
+ t.bigint :source_project_id, null: false
+
+ t.index [:source_project_id, :pipeline_id], unique: true
+ t.index :pipeline_id
+ end
+ end
+end
diff --git a/db/migrate/20200304121828_add_ci_sources_project_pipeline_foreign_key.rb b/db/migrate/20200304121828_add_ci_sources_project_pipeline_foreign_key.rb
new file mode 100644
index 00000000000..db78d9594b0
--- /dev/null
+++ b/db/migrate/20200304121828_add_ci_sources_project_pipeline_foreign_key.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddCiSourcesProjectPipelineForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ with_lock_retries do
+ add_foreign_key :ci_sources_projects, :ci_pipelines, column: :pipeline_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey
+ end
+ end
+end
diff --git a/db/migrate/20200304121844_add_ci_sources_project_source_project_foreign_key.rb b/db/migrate/20200304121844_add_ci_sources_project_source_project_foreign_key.rb
new file mode 100644
index 00000000000..88bf835b9f1
--- /dev/null
+++ b/db/migrate/20200304121844_add_ci_sources_project_source_project_foreign_key.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddCiSourcesProjectSourceProjectForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ with_lock_retries do
+ add_foreign_key :ci_sources_projects, :projects, column: :source_project_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e77e8e44b62..a9cc6d89c6d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -966,6 +966,13 @@ ActiveRecord::Schema.define(version: 2020_03_04_160823) do
t.index ["source_project_id"], name: "index_ci_sources_pipelines_on_source_project_id"
end
+ create_table "ci_sources_projects", force: :cascade do |t|
+ t.bigint "pipeline_id", null: false
+ t.bigint "source_project_id", null: false
+ t.index ["pipeline_id"], name: "index_ci_sources_projects_on_pipeline_id"
+ t.index ["source_project_id", "pipeline_id"], name: "index_ci_sources_projects_on_source_project_id_and_pipeline_id", unique: true
+ end
+
create_table "ci_stages", id: :serial, force: :cascade do |t|
t.integer "project_id"
t.integer "pipeline_id"
@@ -3131,6 +3138,7 @@ ActiveRecord::Schema.define(version: 2020_03_04_160823) do
t.integer "ci_active_jobs", default: 0, null: false
t.integer "project_hooks", default: 0, null: false
t.integer "group_hooks", default: 0, null: false
+ t.integer "ci_project_subscriptions", default: 0, null: false
t.index ["plan_id"], name: "index_plan_limits_on_plan_id", unique: true
end
@@ -4735,6 +4743,8 @@ ActiveRecord::Schema.define(version: 2020_03_04_160823) do
add_foreign_key "ci_sources_pipelines", "ci_pipelines", column: "source_pipeline_id", name: "fk_d4e29af7d7", on_delete: :cascade
add_foreign_key "ci_sources_pipelines", "projects", column: "source_project_id", name: "fk_acd9737679", on_delete: :cascade
add_foreign_key "ci_sources_pipelines", "projects", name: "fk_1e53c97c0a", on_delete: :cascade
+ add_foreign_key "ci_sources_projects", "ci_pipelines", column: "pipeline_id", on_delete: :cascade
+ add_foreign_key "ci_sources_projects", "projects", column: "source_project_id", on_delete: :cascade
add_foreign_key "ci_stages", "ci_pipelines", column: "pipeline_id", name: "fk_fb57e6cc56", on_delete: :cascade
add_foreign_key "ci_stages", "projects", name: "fk_2360681d1d", on_delete: :cascade
add_foreign_key "ci_subscriptions_projects", "projects", column: "downstream_project_id", on_delete: :cascade