Skip to content

Commit

Permalink
Add column file_based_service_bindings_enabled to apps table
Browse files Browse the repository at this point in the history
  • Loading branch information
philippthun committed Oct 1, 2024
1 parent 9bc4a48 commit 33a0df2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Sequel.migration do
change do
add_column :apps, :file_based_service_bindings_enabled, :boolean, default: false, null: false
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper'
require 'migrations/helpers/migration_shared_context'

RSpec.describe 'migration to add file_based_service_bindings_enabled column to apps table', isolation: :truncation, type: :migration do
include_context 'migration' do
let(:migration_filename) { '20240927091800_add_apps_file_based_service_bindings_enabled_column.rb' }
end

describe 'apps table' do
subject(:run_migration) { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }

it 'adds a column `file_based_service_bindings_enabled`' do
expect(db[:apps].columns).not_to include(:file_based_service_bindings_enabled)
run_migration
expect(db[:apps].columns).to include(:file_based_service_bindings_enabled)
end

it 'sets the default value of existing entries to false' do
db[:apps].insert(guid: 'existing_app_guid')
run_migration
expect(db[:apps].first(guid: 'existing_app_guid')[:file_based_service_bindings_enabled]).to be(false)
end

it 'sets the default value of new entries to false' do
run_migration
db[:apps].insert(guid: 'new_app_guid')
expect(db[:apps].first(guid: 'new_app_guid')[:file_based_service_bindings_enabled]).to be(false)
end

it 'forbids null values' do
run_migration
expect { db[:apps].insert(guid: 'app_guid__nil', file_based_service_bindings_enabled: nil) }.to raise_error(Sequel::NotNullConstraintViolation)
end
end
end

0 comments on commit 33a0df2

Please sign in to comment.