From e803e3f26f771b8e424d251951c88892858cb6b1 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 17 Apr 2015 14:28:59 +0300 Subject: cleanup build model --- app/models/build.rb | 13 +------------ app/models/commit.rb | 1 - db/migrate/20150417000045_cleanup_the_build_model.rb | 9 +++++++++ db/schema.rb | 9 +-------- 4 files changed, 11 insertions(+), 21 deletions(-) create mode 100644 db/migrate/20150417000045_cleanup_the_build_model.rb diff --git a/app/models/build.rb b/app/models/build.rb index 3d776ba..da6257a 100644 --- a/app/models/build.rb +++ b/app/models/build.rb @@ -79,7 +79,6 @@ class Build < ActiveRecord::Base new_build.job_id = build.job_id new_build.commit_id = build.commit_id - new_build.ref = build.ref new_build.project_id = build.project_id new_build.save new_build @@ -133,7 +132,7 @@ class Build < ActiveRecord::Base state :canceled, value: 'canceled' end - delegate :sha, :short_sha, :before_sha, + delegate :sha, :short_sha, :before_sha, :ref, to: :commit, prefix: false def trace_html @@ -219,16 +218,6 @@ class Build < ActiveRecord::Base end end - def ref - build_ref = read_attribute(:ref) - - if build_ref.present? - build_ref - else - commit.ref - end - end - def for_tag? if job && job.build_tags true diff --git a/app/models/commit.rb b/app/models/commit.rb index 5f1aa92..6817a9e 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -117,7 +117,6 @@ class Commit < ActiveRecord::Base build.tag_list = job.tag_list build.project_id = project_id build.job = job - build.ref = ref build.save build end diff --git a/db/migrate/20150417000045_cleanup_the_build_model.rb b/db/migrate/20150417000045_cleanup_the_build_model.rb new file mode 100644 index 0000000..1ade714 --- /dev/null +++ b/db/migrate/20150417000045_cleanup_the_build_model.rb @@ -0,0 +1,9 @@ +class CleanupTheBuildModel < ActiveRecord::Migration + def change + remove_column :builds, :push_data + remove_column :builds, :before_sha + remove_column :builds, :ref + remove_column :builds, :sha + remove_column :builds, :tmp_file + end +end diff --git a/db/schema.rb b/db/schema.rb index 65a1032..f16ae4c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,24 +11,19 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150415142013) do +ActiveRecord::Schema.define(version: 20150417000045) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "builds", force: true do |t| t.integer "project_id" - t.string "ref" t.string "status" t.datetime "finished_at" t.text "trace" t.datetime "created_at" t.datetime "updated_at" - t.string "sha" t.datetime "started_at" - t.string "tmp_file" - t.string "before_sha" - t.text "push_data" t.integer "runner_id" t.integer "commit_id" t.float "coverage" @@ -38,10 +33,8 @@ ActiveRecord::Schema.define(version: 20150415142013) do add_index "builds", ["commit_id"], name: "index_builds_on_commit_id", using: :btree add_index "builds", ["project_id", "commit_id"], name: "index_builds_on_project_id_and_commit_id", using: :btree - add_index "builds", ["project_id", "sha"], name: "index_builds_on_project_id_and_sha", using: :btree add_index "builds", ["project_id"], name: "index_builds_on_project_id", using: :btree add_index "builds", ["runner_id"], name: "index_builds_on_runner_id", using: :btree - add_index "builds", ["sha"], name: "index_builds_on_sha", using: :btree create_table "commits", force: true do |t| t.integer "project_id" -- cgit v1.2.1