summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-04-15 17:51:34 +0300
committerValery Sizov <vsv2711@gmail.com>2015-04-15 17:51:34 +0300
commit6f5904035606504f557616b3957598f2918587fa (patch)
tree920d25c15f067707c2876793aa7ed1fcd79db3b0
parent475158fec68d3071bcbd0377133b6ac0d9710136 (diff)
downloadgitlab-ci-6f5904035606504f557616b3957598f2918587fa.tar.gz
Job soft deletion
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock3
-rw-r--r--app/models/build.rb2
-rw-r--r--app/models/job.rb2
-rw-r--r--db/migrate/20150415142013_add_deleted_at_to_jobs.rb6
-rw-r--r--db/schema.rb4
6 files changed, 18 insertions, 2 deletions
diff --git a/Gemfile b/Gemfile
index 79b5fa3..778b4eb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -79,6 +79,9 @@ gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'nprogress-rails'
+# Soft deletion
+gem "paranoia", "~> 2.0"
+
group :development do
gem 'brakeman', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index 8d66913..9160d12 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -201,6 +201,8 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
+ paranoia (2.1.1)
+ activerecord (~> 4.0)
parser (2.2.0.2)
ast (>= 1.1, < 3.0)
pg (0.17.0)
@@ -396,6 +398,7 @@ DEPENDENCIES
nested_form
nprogress-rails
oauth2 (= 1.0.0)
+ paranoia (~> 2.0)
pg
poltergeist (~> 1.5.1)
pry
diff --git a/app/models/build.rb b/app/models/build.rb
index cad3247..3d776ba 100644
--- a/app/models/build.rb
+++ b/app/models/build.rb
@@ -28,7 +28,7 @@ class Build < ActiveRecord::Base
belongs_to :commit
belongs_to :project
belongs_to :runner
- belongs_to :job
+ belongs_to :job, -> { with_deleted }
validates :commit, presence: true
validates :status, presence: true
diff --git a/app/models/job.rb b/app/models/job.rb
index 82dac8f..14cc344 100644
--- a/app/models/job.rb
+++ b/app/models/job.rb
@@ -16,6 +16,8 @@
#
class Job < ActiveRecord::Base
+ acts_as_paranoid
+
belongs_to :project
has_many :builds
diff --git a/db/migrate/20150415142013_add_deleted_at_to_jobs.rb b/db/migrate/20150415142013_add_deleted_at_to_jobs.rb
new file mode 100644
index 0000000..7a825a2
--- /dev/null
+++ b/db/migrate/20150415142013_add_deleted_at_to_jobs.rb
@@ -0,0 +1,6 @@
+class AddDeletedAtToJobs < ActiveRecord::Migration
+ def change
+ add_column :jobs, :deleted_at, :datetime
+ add_index :jobs, :deleted_at
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e194f7a..65a1032 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: 20150330001111) do
+ActiveRecord::Schema.define(version: 20150415142013) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -81,8 +81,10 @@ ActiveRecord::Schema.define(version: 20150330001111) do
t.boolean "build_tags", default: false, null: false
t.string "job_type", default: "parallel"
t.string "refs"
+ t.datetime "deleted_at"
end
+ add_index "jobs", ["deleted_at"], name: "index_jobs_on_deleted_at", using: :btree
add_index "jobs", ["project_id"], name: "index_jobs_on_project_id", using: :btree
create_table "projects", force: true do |t|