diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2018-03-05 17:35:06 +0100 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2018-03-28 13:57:41 +0200 |
commit | bb64b20a1f7dd831e4c200343b531f9d048c02a8 (patch) | |
tree | 6223c95875e53a235bde1b26f9b06a1776acb1ca /db | |
parent | 9ef86b1b12e80bcc3a6277e2b6a36b793c828489 (diff) | |
download | gitlab-ce-bb64b20a1f7dd831e4c200343b531f9d048c02a8.tar.gz |
Refactorize Ci::Build and Ci::BuildMetadata models
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180301010859_create_ci_builds_metadata_table.rb | 7 | ||||
-rw-r--r-- | db/migrate/20180301011323_add_build_foreign_key_to_ci_builds_metadata.rb | 15 | ||||
-rw-r--r-- | db/schema.rb | 7 |
3 files changed, 8 insertions, 21 deletions
diff --git a/db/migrate/20180301010859_create_ci_builds_metadata_table.rb b/db/migrate/20180301010859_create_ci_builds_metadata_table.rb index 9d5e9c1779b..cd7824d7788 100644 --- a/db/migrate/20180301010859_create_ci_builds_metadata_table.rb +++ b/db/migrate/20180301010859_create_ci_builds_metadata_table.rb @@ -4,10 +4,13 @@ class CreateCiBuildsMetadataTable < ActiveRecord::Migration DOWNTIME = false def change - create_table :ci_builds_metadata do |t| + create_table :ci_builds_metadata, id: false do |t| t.integer :build_id, null: false t.integer :used_timeout - t.integer :timeout_source + t.integer :timeout_source, null: false, default: 1 + + t.primary_key :build_id + t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade end end end diff --git a/db/migrate/20180301011323_add_build_foreign_key_to_ci_builds_metadata.rb b/db/migrate/20180301011323_add_build_foreign_key_to_ci_builds_metadata.rb deleted file mode 100644 index feda2d6e9c9..00000000000 --- a/db/migrate/20180301011323_add_build_foreign_key_to_ci_builds_metadata.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddBuildForeignKeyToCiBuildsMetadata < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_foreign_key(:ci_builds_metadata, :ci_builds, column: :build_id) - end - - def down - remove_foreign_key(:ci_builds_metadata, column: :build_id) - end -end diff --git a/db/schema.rb b/db/schema.rb index 5463b3f1219..920d71e0110 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -329,10 +329,9 @@ ActiveRecord::Schema.define(version: 20180327101207) do add_index "ci_builds", ["updated_at"], name: "index_ci_builds_on_updated_at", using: :btree add_index "ci_builds", ["user_id"], name: "index_ci_builds_on_user_id", using: :btree - create_table "ci_builds_metadata", force: :cascade do |t| - t.integer "build_id", null: false + create_table "ci_builds_metadata", primary_key: "build_id", force: :cascade do |t| t.integer "used_timeout" - t.integer "timeout_source" + t.integer "timeout_source", default: 1, null: false end create_table "ci_group_variables", force: :cascade do |t| @@ -2035,7 +2034,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do add_foreign_key "ci_builds", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_a2141b1522", on_delete: :nullify add_foreign_key "ci_builds", "ci_stages", column: "stage_id", name: "fk_3a9eaa254d", on_delete: :cascade add_foreign_key "ci_builds", "projects", name: "fk_befce0568a", on_delete: :cascade - add_foreign_key "ci_builds_metadata", "ci_builds", column: "build_id", name: "fk_e20479742e", on_delete: :cascade + add_foreign_key "ci_builds_metadata", "ci_builds", column: "build_id", on_delete: :cascade add_foreign_key "ci_group_variables", "namespaces", column: "group_id", name: "fk_33ae4d58d8", on_delete: :cascade add_foreign_key "ci_job_artifacts", "ci_builds", column: "job_id", on_delete: :cascade add_foreign_key "ci_job_artifacts", "projects", on_delete: :cascade |