2022-08-08 16:06:00 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UpdateLabelTemplates < ActiveRecord::Migration[6.1]
|
|
|
|
def up
|
|
|
|
change_table :label_templates, bulk: true do |t|
|
|
|
|
t.string :type
|
|
|
|
t.float :width_mm
|
|
|
|
t.float :height_mm
|
|
|
|
t.remove :format
|
|
|
|
t.remove :language_type
|
|
|
|
t.remove :size
|
|
|
|
end
|
|
|
|
|
2022-08-08 17:21:38 +08:00
|
|
|
LabelTemplate.reset_column_information
|
|
|
|
|
2022-08-08 16:06:00 +08:00
|
|
|
# Remove our original default template
|
|
|
|
LabelTemplate.order(created_at: :asc).find_by(default: true)&.destroy
|
|
|
|
|
2022-10-12 21:03:55 +08:00
|
|
|
Team.find_each do |team|
|
|
|
|
FluicsLabelTemplate.create!(
|
|
|
|
name: I18n.t('label_templates.default_fluics_name'),
|
|
|
|
width_mm: 25.4,
|
|
|
|
height_mm: 12.7,
|
|
|
|
content: Extends::DEFAULT_LABEL_TEMPLATE[:zpl],
|
2022-10-12 21:47:10 +08:00
|
|
|
team: team,
|
|
|
|
default: true
|
2022-10-12 21:03:55 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
ZebraLabelTemplate.create!(
|
|
|
|
name: I18n.t('label_templates.default_zebra_name'),
|
|
|
|
width_mm: 25.4,
|
|
|
|
height_mm: 12.7,
|
|
|
|
content: Extends::DEFAULT_LABEL_TEMPLATE[:zpl],
|
2022-10-12 21:47:10 +08:00
|
|
|
team: team,
|
|
|
|
default: true
|
2022-10-12 21:03:55 +08:00
|
|
|
)
|
|
|
|
end
|
2022-08-08 16:06:00 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
change_table :label_templates, bulk: true do |t|
|
|
|
|
t.remove :type
|
|
|
|
t.remove :width_mm
|
2022-08-08 17:21:38 +08:00
|
|
|
t.remove :height_mm
|
2022-08-08 16:06:00 +08:00
|
|
|
t.string :format, null: false, default: 'ZPL'
|
|
|
|
t.integer :language_type
|
|
|
|
t.string :size
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|