Add explicit primary key for ci_builds_metadata table

This commit is contained in:
Tomasz Maczukin 2018-03-26 18:58:35 +02:00
parent 7008ed1e33
commit 403decbbad
No known key found for this signature in database
GPG Key ID: 7E9EB2E4B0F625CD
3 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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|