diff --git a/app/models/booking_validation.rb b/app/models/booking_validation.rb index c0e1c597c..a207ee6c0 100644 --- a/app/models/booking_validation.rb +++ b/app/models/booking_validation.rb @@ -4,21 +4,18 @@ # # Table name: booking_validations # -# id :bigint not null, primary key +# id :integer not null, primary key +# organisation_id :integer not null # error_message_i18n :jsonb # ordinal :integer # created_at :datetime not null # updated_at :datetime not null -# organisation_id :bigint not null # # Indexes # # index_booking_validations_on_organisation_id (organisation_id) # -# Foreign Keys -# -# fk_rails_... (organisation_id => organisations.id) -# + class BookingValidation < ApplicationRecord extend Mobility include RankedModel diff --git a/db/migrate/20241129161448_set_locale_for_existing_contracts.rb b/db/migrate/20241129161448_set_locale_for_existing_contracts.rb index 1a8f88b55..54171381c 100644 --- a/db/migrate/20241129161448_set_locale_for_existing_contracts.rb +++ b/db/migrate/20241129161448_set_locale_for_existing_contracts.rb @@ -1,10 +1,9 @@ class SetLocaleForExistingContracts < ActiveRecord::Migration[8.0] def up - Booking.where(concluded: false).find_each do |booking| - next if booking.contract.blank? - + Booking.where(concluded: false).joins(:contracts).includes(:contracts) + .where.not(contracts: { id: nil }).find_each do |booking| booking.contract.skip_generate_pdf = true - booking.contract.update(locale: booking.locale) + booking.contract.update_columns(locale: booking.locale) end end end diff --git a/spec/factories/booking_validations.rb b/spec/factories/booking_validations.rb index ba1a19a25..afb44a018 100644 --- a/spec/factories/booking_validations.rb +++ b/spec/factories/booking_validations.rb @@ -4,21 +4,18 @@ # # Table name: booking_validations # -# id :bigint not null, primary key +# id :integer not null, primary key +# organisation_id :integer not null # error_message_i18n :jsonb # ordinal :integer # created_at :datetime not null # updated_at :datetime not null -# organisation_id :bigint not null # # Indexes # # index_booking_validations_on_organisation_id (organisation_id) # -# Foreign Keys -# -# fk_rails_... (organisation_id => organisations.id) -# + FactoryBot.define do factory :booking_validation do organisation { nil } diff --git a/spec/models/booking_validation_spec.rb b/spec/models/booking_validation_spec.rb index 0a37966e7..630ae3844 100644 --- a/spec/models/booking_validation_spec.rb +++ b/spec/models/booking_validation_spec.rb @@ -4,21 +4,18 @@ # # Table name: booking_validations # -# id :bigint not null, primary key +# id :integer not null, primary key +# organisation_id :integer not null # error_message_i18n :jsonb # ordinal :integer # created_at :datetime not null # updated_at :datetime not null -# organisation_id :bigint not null # # Indexes # # index_booking_validations_on_organisation_id (organisation_id) # -# Foreign Keys -# -# fk_rails_... (organisation_id => organisations.id) -# + require 'rails_helper' RSpec.describe BookingValidation, type: :model do