Skip to content

Commit 1ca9162

Browse files
committed
Add column 'service_binding_k8s_enabled' to apps table
1 parent fad2da1 commit 1ca9162

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Sequel.migration do
2+
change do
3+
add_column :apps, :service_binding_k8s_enabled, :boolean, default: false, null: false
4+
end
5+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
require 'spec_helper'
2+
require 'migrations/helpers/migration_shared_context'
3+
4+
RSpec.describe 'migration to add service_binding_k8s_enabled column to apps table', isolation: :truncation, type: :migration do
5+
include_context 'migration' do
6+
let(:migration_filename) { '20250225132929_add_apps_service_binding_k8s_enabled_column.rb' }
7+
end
8+
9+
describe 'apps table' do
10+
subject(:run_migration) { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }
11+
12+
it 'adds a column `service_binding_k8s_enabled`' do
13+
expect(db[:apps].columns).not_to include(:service_binding_k8s_enabled)
14+
run_migration
15+
expect(db[:apps].columns).to include(:service_binding_k8s_enabled)
16+
end
17+
18+
it 'sets the default value of existing entries to false' do
19+
db[:apps].insert(guid: 'existing_app_guid')
20+
run_migration
21+
expect(db[:apps].first(guid: 'existing_app_guid')[:service_binding_k8s_enabled]).to be(false)
22+
end
23+
24+
it 'sets the default value of new entries to false' do
25+
run_migration
26+
db[:apps].insert(guid: 'new_app_guid')
27+
expect(db[:apps].first(guid: 'new_app_guid')[:service_binding_k8s_enabled]).to be(false)
28+
end
29+
30+
it 'forbids null values' do
31+
run_migration
32+
expect { db[:apps].insert(guid: 'app_guid__nil', service_binding_k8s_enabled: nil) }.to raise_error(Sequel::NotNullConstraintViolation)
33+
end
34+
end
35+
end

0 commit comments

Comments
 (0)