Skip to content

Commit

Permalink
DestroyStackJob: also delete commits
Browse files Browse the repository at this point in the history
Also use `dependent: :delete` rather than destroy for models
that don't have an `after_destroy` callback.
  • Loading branch information
byroot committed Nov 14, 2024
1 parent 50ab00a commit 5c059ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/jobs/shipit/destroy_stack_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def perform(stack)

delete(Shipit::OutputChunk.joins(:task).where(task: { stack_id: stack.id }))
delete(Shipit::Task.where(stack_id: stack.id))

delete(Shipit::Commit.where(stack_id: stack.id))

stack.destroy!
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/shipit/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def blank?
has_many :github_hooks, dependent: :destroy, class_name: 'Shipit::GithubHook::Repo'
has_many :hooks, dependent: :destroy
has_many :api_clients, dependent: :destroy
has_one :continuous_delivery_schedule
has_one :continuous_delivery_schedule, dependent: :destroy
belongs_to :lock_author, class_name: :User, optional: true
belongs_to :repository
validates_associated :repository
Expand Down

0 comments on commit 5c059ce

Please sign in to comment.