diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-02-15 17:23:39 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-02-15 17:39:35 +0100 |
commit | 03345b3613d7667bd0ef05ec2258049e58d355ec (patch) | |
tree | 44288c6cdb9ab47bc5f2e40d4640a05874c6c8b0 /db | |
parent | e7f99753dae4de7422836ebf5f72e0dba3a867bb (diff) | |
download | gitlab-ce-remove-trigger-requests.tar.gz |
Remove trigger request and migrate all data to pipeline, by adding trigger_id and trigger_variables.remove-trigger-requests
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20170215155650_add_trigger_request_id_to_pipeline.rb | 14 | ||||
-rw-r--r-- | db/migrate/20170215160640_migrate_trigger_id_to_pipeline.rb | 16 | ||||
-rw-r--r-- | db/migrate/20170215160655_add_trigger_id_index.rb | 11 | ||||
-rw-r--r-- | db/schema.rb | 8 |
4 files changed, 47 insertions, 2 deletions
diff --git a/db/migrate/20170215155650_add_trigger_request_id_to_pipeline.rb b/db/migrate/20170215155650_add_trigger_request_id_to_pipeline.rb new file mode 100644 index 00000000000..6c923b4eb23 --- /dev/null +++ b/db/migrate/20170215155650_add_trigger_request_id_to_pipeline.rb @@ -0,0 +1,14 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddTriggerRequestIdToPipeline < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_commits, :trigger_id, :integer + add_column :ci_commits, :trigger_variables, :text + add_foreign_key :ci_commits, :ci_triggers, column: "trigger_id", on_delete: :cascade + end +end diff --git a/db/migrate/20170215160640_migrate_trigger_id_to_pipeline.rb b/db/migrate/20170215160640_migrate_trigger_id_to_pipeline.rb new file mode 100644 index 00000000000..ed70cd7cfd3 --- /dev/null +++ b/db/migrate/20170215160640_migrate_trigger_id_to_pipeline.rb @@ -0,0 +1,16 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class MigrateTriggerIdToPipeline < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + execute("UPDATE ci_commits SET " + + "trigger_id = triggers.trigger_id, " + + "trigger_variables = triggers.variables " + + "FROM (SELECT commit_id, trigger_id, variables FROM ci_trigger_requests) as triggers " + + "WHERE ci_commits.id = triggers.commit_id") + end +end diff --git a/db/migrate/20170215160655_add_trigger_id_index.rb b/db/migrate/20170215160655_add_trigger_id_index.rb new file mode 100644 index 00000000000..26122d6bcbb --- /dev/null +++ b/db/migrate/20170215160655_add_trigger_id_index.rb @@ -0,0 +1,11 @@ +class AddTriggerIdIndex < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def change + add_concurrent_index :ci_commits, [:gl_project_id, :trigger_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index 3dde4b9c82b..d467164bca1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170211073944) do +ActiveRecord::Schema.define(version: 20170215160655) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -249,10 +249,13 @@ ActiveRecord::Schema.define(version: 20170211073944) do t.integer "duration" t.integer "user_id" t.integer "lock_version" + t.integer "trigger_id" + t.text "trigger_variables" end add_index "ci_commits", ["gl_project_id", "sha"], name: "index_ci_commits_on_gl_project_id_and_sha", using: :btree add_index "ci_commits", ["gl_project_id", "status"], name: "index_ci_commits_on_gl_project_id_and_status", using: :btree + add_index "ci_commits", ["gl_project_id", "trigger_id"], name: "index_ci_commits_on_gl_project_id_and_trigger_id", using: :btree add_index "ci_commits", ["gl_project_id"], name: "index_ci_commits_on_gl_project_id", using: :btree add_index "ci_commits", ["status"], name: "index_ci_commits_on_status", using: :btree add_index "ci_commits", ["user_id"], name: "index_ci_commits_on_user_id", using: :btree @@ -580,9 +583,9 @@ ActiveRecord::Schema.define(version: 20170211073944) do end add_index "labels", ["group_id", "project_id", "title"], name: "index_labels_on_group_id_and_project_id_and_title", unique: true, using: :btree - add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree add_index "labels", ["title"], name: "index_labels_on_title", using: :btree + add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree create_table "lfs_objects", force: :cascade do |t| t.string "oid", null: false @@ -1330,6 +1333,7 @@ ActiveRecord::Schema.define(version: 20170211073944) do add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree add_foreign_key "boards", "projects" + add_foreign_key "ci_commits", "ci_triggers", column: "trigger_id", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade add_foreign_key "label_priorities", "projects", on_delete: :cascade |