Skip to content

Commit 5c059ce

Browse files
committed
DestroyStackJob: also delete commits
Also use `dependent: :delete` rather than destroy for models that don't have an `after_destroy` callback.
1 parent 50ab00a commit 5c059ce

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

app/jobs/shipit/destroy_stack_job.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ def perform(stack)
3232

3333
delete(Shipit::OutputChunk.joins(:task).where(task: { stack_id: stack.id }))
3434
delete(Shipit::Task.where(stack_id: stack.id))
35+
36+
delete(Shipit::Commit.where(stack_id: stack.id))
37+
3538
stack.destroy!
3639
end
3740

app/models/shipit/stack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def blank?
3838
has_many :github_hooks, dependent: :destroy, class_name: 'Shipit::GithubHook::Repo'
3939
has_many :hooks, dependent: :destroy
4040
has_many :api_clients, dependent: :destroy
41-
has_one :continuous_delivery_schedule
41+
has_one :continuous_delivery_schedule, dependent: :destroy
4242
belongs_to :lock_author, class_name: :User, optional: true
4343
belongs_to :repository
4444
validates_associated :repository

0 commit comments

Comments
 (0)