From 5d7c024056ecc6914720d1554738b2bf10ea72ae Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 7 Jun 2021 14:15:39 +0200 Subject: [PATCH] fix stripe_ids data migration --- app/validators/period_integrity_validator.rb | 7 +------ ...083610_migrate_stripe_ids_to_payment_gateway_objects.rb | 4 ++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/validators/period_integrity_validator.rb b/app/validators/period_integrity_validator.rb index 8dc8e6f11..9f0d735f0 100644 --- a/app/validators/period_integrity_validator.rb +++ b/app/validators/period_integrity_validator.rb @@ -3,12 +3,7 @@ # Validates that all invoices in the current accounting period are chained with footprints which ensure their integrity class PeriodIntegrityValidator < ActiveModel::Validator def validate(record) - the_end = record.end_at - the_start = record.start_at - - invoices = Invoice.where('created_at >= :start_date AND created_at < :end_date', start_date: the_start, end_date: the_end) - .includes(:invoice_items) - + invoices = record.invoices.includes(:invoice_items) invoices.each do |i| record.errors["invoice_#{i.reference}".to_sym] << I18n.t('errors.messages.invalid_footprint') unless i.check_footprint diff --git a/db/migrate/20210416083610_migrate_stripe_ids_to_payment_gateway_objects.rb b/db/migrate/20210416083610_migrate_stripe_ids_to_payment_gateway_objects.rb index 86417c7d4..162663385 100644 --- a/db/migrate/20210416083610_migrate_stripe_ids_to_payment_gateway_objects.rb +++ b/db/migrate/20210416083610_migrate_stripe_ids_to_payment_gateway_objects.rb @@ -34,6 +34,8 @@ class MigrateStripeIdsToPaymentGatewayObjects < ActiveRecord::Migration[5.2] end remove_column :invoices, :stp_invoice_id remove_column :invoices, :stp_payment_intent_id + Invoice.connection.schema_cache.clear! + Invoice.reset_column_information ## INVOICE ITEMS puts 'Migrating invoices items...' @@ -48,6 +50,8 @@ class MigrateStripeIdsToPaymentGatewayObjects < ActiveRecord::Migration[5.2] ) end remove_column :invoice_items, :stp_invoice_item_id + InvoiceItem.connection.schema_cache.clear! + InvoiceItem.reset_column_information ## SUBSCRIPTIONS # stp_subscription_id is not used anymore.