Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC0030 - 1] Add column file_based_service_bindings_enabled to apps table #3996

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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