Skip to content

Commit 5e77dab

Browse files
authored
Add column file_based_service_bindings_enabled to apps table (#3996)
1 parent baf0ad4 commit 5e77dab

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, :file_based_service_bindings_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 file_based_service_bindings_enabled column to apps table', isolation: :truncation, type: :migration do
5+
include_context 'migration' do
6+
let(:migration_filename) { '20241203085500_add_apps_file_based_service_bindings_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 `file_based_service_bindings_enabled`' do
13+
expect(db[:apps].columns).not_to include(:file_based_service_bindings_enabled)
14+
run_migration
15+
expect(db[:apps].columns).to include(:file_based_service_bindings_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')[:file_based_service_bindings_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')[:file_based_service_bindings_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', file_based_service_bindings_enabled: nil) }.to raise_error(Sequel::NotNullConstraintViolation)
33+
end
34+
end
35+
end

0 commit comments

Comments
 (0)