-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3538 from sap-contributions/clean-up-degenerate-d…
…eployments Clean up degenerate deployments
- Loading branch information
Showing
7 changed files
with
35 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
db/migrations/20231205143526_remove_deployments_with_degenerate.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Sequel.migration do | ||
up do | ||
degenerate_records = self[:deployments].where(status_reason: 'DEGENERATE') | ||
degenerate_records.delete | ||
end | ||
|
||
down do | ||
# It is not possible to recover the deleted rows during rollback | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
spec/migrations/20231205143526_remove_deployments_with_degenerate_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'spec_helper' | ||
require 'migrations/helpers/migration_shared_context' | ||
|
||
RSpec.describe 'migration to clean up degenerate records from deployments records', isolation: :truncation do | ||
include_context 'migration' do | ||
let(:migration_filename) { '20231205143526_remove_deployments_with_degenerate.rb' } | ||
end | ||
|
||
describe 'deployments table' do | ||
it 'degenerate record is removed from deployments' do | ||
db[:deployments].insert( | ||
guid: 'bommel', | ||
original_web_process_instance_count: 1, | ||
status_reason: 'DEGENERATE' | ||
) | ||
|
||
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true) }.not_to raise_error | ||
deployment = db[:deployments].first(status_reason: 'DEGENERATE') | ||
expect(deployment).to be_nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters