diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-09-24 19:17:04 +0900 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2018-10-02 17:04:04 +0200 |
commit | f97ec4b8f44152036a8f8242bcf1584cfbd56cec (patch) | |
tree | 8bdf251d1f9dadfe0299c4b43a6fe52413216ce3 /db | |
parent | 571a934f29bee7af9569176e62e5376b471e35fb (diff) | |
download | gitlab-ce-f97ec4b8f44152036a8f8242bcf1584cfbd56cec.tar.gz |
Add scheduled_at column to ci_builds, and add a partial index as well
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180913102839_create_build_schedules.rb | 19 | ||||
-rw-r--r-- | db/migrate/20180924190739_add_scheduled_at_to_ci_builds.rb | 9 | ||||
-rw-r--r-- | db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb | 18 | ||||
-rw-r--r-- | db/schema.rb | 5 |
4 files changed, 31 insertions, 20 deletions
diff --git a/db/migrate/20180913102839_create_build_schedules.rb b/db/migrate/20180913102839_create_build_schedules.rb deleted file mode 100644 index 1e9d9a70b0f..00000000000 --- a/db/migrate/20180913102839_create_build_schedules.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class CreateBuildSchedules < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def change - create_table :ci_build_schedules, id: :bigserial do |t| - t.integer :build_id, null: false - t.datetime :execute_at, null: false - - t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade - t.index :build_id, unique: true - end - end -end diff --git a/db/migrate/20180924190739_add_scheduled_at_to_ci_builds.rb b/db/migrate/20180924190739_add_scheduled_at_to_ci_builds.rb new file mode 100644 index 00000000000..c163fbb1fd6 --- /dev/null +++ b/db/migrate/20180924190739_add_scheduled_at_to_ci_builds.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddScheduledAtToCiBuilds < ActiveRecord::Migration + DOWNTIME = false + + def change + add_column :ci_builds, :scheduled_at, :datetime_with_timezone + end +end diff --git a/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb b/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb new file mode 100644 index 00000000000..1b79365a0f6 --- /dev/null +++ b/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddPartialIndexToScheduledAt < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'partial_index_ci_builds_on_id_with_scheduled_jobs'.freeze + + disable_ddl_transaction! + + def up + add_concurrent_index(:ci_builds, :id, where: "scheduled_at <> NULL", name: INDEX_NAME) + end + + def down + remove_concurrent_index_by_name(:ci_builds, INDEX_NAME) + end +end diff --git a/db/schema.rb b/db/schema.rb index 581496d78ce..ff45c9effc6 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: 20180924141949) do +ActiveRecord::Schema.define(version: 20180924201039) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -341,6 +341,7 @@ ActiveRecord::Schema.define(version: 20180924141949) do t.integer "artifacts_metadata_store" t.boolean "protected" t.integer "failure_reason" + t.datetime_with_timezone "scheduled_at" end add_index "ci_builds", ["artifacts_expire_at"], name: "index_ci_builds_on_artifacts_expire_at", where: "(artifacts_file <> ''::text)", using: :btree @@ -350,6 +351,7 @@ ActiveRecord::Schema.define(version: 20180924141949) do add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree add_index "ci_builds", ["id"], name: "partial_index_ci_builds_on_id_with_legacy_artifacts", where: "(artifacts_file <> ''::text)", using: :btree + add_index "ci_builds", ["id"], name: "partial_index_ci_builds_on_id_with_scheduled_jobs", where: "(scheduled_at <> NULL::timestamp with time zone)", using: :btree add_index "ci_builds", ["project_id", "id"], name: "index_ci_builds_on_project_id_and_id", using: :btree add_index "ci_builds", ["protected"], name: "index_ci_builds_on_protected", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree @@ -1799,6 +1801,7 @@ ActiveRecord::Schema.define(version: 20180924141949) do end add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree + add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree create_table "releases", force: :cascade do |t| |