2021-07-19 15:44:14 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class CreateLabelTemplates < ActiveRecord::Migration[6.1]
|
2021-07-20 15:35:39 +08:00
|
|
|
class LabelTemplate < ApplicationRecord
|
|
|
|
enum language_type: { zpl: 0 }
|
|
|
|
end
|
|
|
|
|
2021-07-19 15:44:14 +08:00
|
|
|
def change
|
|
|
|
create_table :label_templates do |t|
|
|
|
|
t.string :name, null: false
|
|
|
|
t.text :content, null: false
|
|
|
|
t.integer :language_type, index: true
|
|
|
|
t.boolean :default, default: false, null: false
|
|
|
|
t.string :size
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
|
|
|
LabelTemplate.create(
|
|
|
|
name: 'SciNote Item',
|
|
|
|
size: '1" x 0.5" / 25.4mm x 12.7mm',
|
|
|
|
language_type: :zpl,
|
|
|
|
default: true,
|
|
|
|
content:
|
|
|
|
<<~HEREDOC
|
|
|
|
^XA
|
2022-05-09 16:15:46 +08:00
|
|
|
^MTT
|
|
|
|
^MUD,300,300
|
|
|
|
^PR2
|
|
|
|
^MD30
|
2021-08-24 15:52:29 +08:00
|
|
|
^LH20,20
|
2022-05-09 16:15:46 +08:00
|
|
|
^PW310
|
2021-08-24 15:52:29 +08:00
|
|
|
^CF0,23
|
2021-08-30 16:38:59 +08:00
|
|
|
^FO0,0^FD{{item_id}}^FS
|
2022-05-09 16:15:46 +08:00
|
|
|
^FO0,20^BQN,2,4^FDMA,{{item_id}}^FS
|
2021-08-24 15:52:29 +08:00
|
|
|
^FO95,30^FB180,4,0,L^FD{{item_name}}^FS^FS
|
2021-07-19 15:44:14 +08:00
|
|
|
^XZ
|
|
|
|
HEREDOC
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|