Migration fixes [SCI-7046] (#4321)

This commit is contained in:
artoscinote 2022-08-08 11:21:38 +02:00 committed by GitHub
parent eb619184a5
commit 464f9935a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -40,7 +40,7 @@ class LabelTemplate < ApplicationRecord
private
def ensure_single_default_template!
if default && self.class.where(team_id: team_id, default: true, language_type: language_type)
if default && self.class.where(team_id: team_id, default: true, type: type)
.where.not(id: id).any?
errors.add(:default, I18n.t('activerecord.errors.models.label_template.attributes.default.already_exist'))
end

View file

@ -11,6 +11,8 @@ class UpdateLabelTemplates < ActiveRecord::Migration[6.1]
t.remove :size
end
LabelTemplate.reset_column_information
# Remove our original default template
LabelTemplate.order(created_at: :asc).find_by(default: true)&.destroy
@ -21,7 +23,7 @@ class UpdateLabelTemplates < ActiveRecord::Migration[6.1]
change_table :label_templates, bulk: true do |t|
t.remove :type
t.remove :width_mm
t.remoe :height_mm
t.remove :height_mm
t.string :format, null: false, default: 'ZPL'
t.integer :language_type
t.string :size