diff options
-rw-r--r-- | app/models/build.rb | 1 | ||||
-rw-r--r-- | app/models/commit.rb | 5 | ||||
-rw-r--r-- | app/models/job.rb | 1 | ||||
-rw-r--r-- | db/migrate/20141103162726_add_job_id_to_build.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 3 |
5 files changed, 13 insertions, 2 deletions
diff --git a/app/models/build.rb b/app/models/build.rb index b100a4b..de69fd6 100644 --- a/app/models/build.rb +++ b/app/models/build.rb @@ -19,6 +19,7 @@ class Build < ActiveRecord::Base belongs_to :commit belongs_to :runner + belongs_to :job attr_accessible :status, :finished_at, :trace, :started_at, :runner_id, :commit_id, :coverage, :commands diff --git a/app/models/commit.rb b/app/models/commit.rb index bad8896..cb08c24 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -97,7 +97,10 @@ class Commit < ActiveRecord::Base def create_builds project.jobs.active.map do |job| - builds.create(commands: job.commands) + build = builds.new(commands: job.commands) + build.job = job + build.save + build end end end diff --git a/app/models/job.rb b/app/models/job.rb index 031fc1c..9ebc9aa 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -1,5 +1,6 @@ class Job < ActiveRecord::Base belongs_to :project + has_many :builds scope :active, ->() { where(active: true) } scope :archived, ->() { where(active: false) } diff --git a/db/migrate/20141103162726_add_job_id_to_build.rb b/db/migrate/20141103162726_add_job_id_to_build.rb new file mode 100644 index 0000000..b4e3020 --- /dev/null +++ b/db/migrate/20141103162726_add_job_id_to_build.rb @@ -0,0 +1,5 @@ +class AddJobIdToBuild < ActiveRecord::Migration + def change + add_column :builds, :job_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 500c1aa..9cd7f01 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: 20141103151359) do +ActiveRecord::Schema.define(version: 20141103162726) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -33,6 +33,7 @@ ActiveRecord::Schema.define(version: 20141103151359) do t.float "coverage" t.integer "commit_id" t.text "commands" + t.integer "job_id" end add_index "builds", ["commit_id"], name: "index_builds_on_commit_id", using: :btree |