summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2018-03-26 18:58:35 +0200
committerTomasz Maczukin <tomasz@maczukin.pl>2018-03-28 14:00:04 +0200
commit403decbbad26bea620125aed34b440a9b6611172 (patch)
tree1c587d73c314873a113d27f4c271866770d6a57e
parent7008ed1e33bff510126a0eb0e4f7bf1a7adb02bd (diff)
downloadgitlab-ce-403decbbad26bea620125aed34b440a9b6611172.tar.gz
Add explicit primary key for ci_builds_metadata table
-rw-r--r--app/models/ci/build_metadata.rb1
-rw-r--r--db/migrate/20180301010859_create_ci_builds_metadata_table.rb4
-rw-r--r--db/schema.rb4
3 files changed, 6 insertions, 3 deletions
diff --git a/app/models/ci/build_metadata.rb b/app/models/ci/build_metadata.rb
index de5b4170201..96762f8845c 100644
--- a/app/models/ci/build_metadata.rb
+++ b/app/models/ci/build_metadata.rb
@@ -11,6 +11,7 @@ module Ci
belongs_to :build, class_name: 'Ci::Build'
belongs_to :project
+ validates :build, presence: true
validates :project, presence: true
chronic_duration_attr_reader :timeout_human_readable, :timeout
diff --git a/db/migrate/20180301010859_create_ci_builds_metadata_table.rb b/db/migrate/20180301010859_create_ci_builds_metadata_table.rb
index 650bf43835d..ce737444092 100644
--- a/db/migrate/20180301010859_create_ci_builds_metadata_table.rb
+++ b/db/migrate/20180301010859_create_ci_builds_metadata_table.rb
@@ -4,16 +4,16 @@ class CreateCiBuildsMetadataTable < ActiveRecord::Migration
DOWNTIME = false
def change
- create_table :ci_builds_metadata, id: false do |t|
+ create_table :ci_builds_metadata do |t|
t.integer :build_id, null: false
t.integer :project_id, null: false
t.integer :timeout
t.integer :timeout_source, null: false, default: 1
- t.primary_key :build_id
t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade
t.foreign_key :projects, column: :project_id, on_delete: :cascade
+ t.index :build_id, unique: true
t.index :project_id
end
end
diff --git a/db/schema.rb b/db/schema.rb
index 56541aa4ecd..3d3a4c0ce4a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -329,12 +329,14 @@ 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", primary_key: "build_id", force: :cascade do |t|
+ create_table "ci_builds_metadata", force: :cascade do |t|
+ t.integer "build_id", null: false
t.integer "project_id", null: false
t.integer "timeout"
t.integer "timeout_source", default: 1, null: false
end
+ add_index "ci_builds_metadata", ["build_id"], name: "index_ci_builds_metadata_on_build_id", unique: true, using: :btree
add_index "ci_builds_metadata", ["project_id"], name: "index_ci_builds_metadata_on_project_id", using: :btree
create_table "ci_group_variables", force: :cascade do |t|