4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/netfira/web_connect/db_schema/20140515_alpha.rb', line 4
def change
def product(t)
t.decimal :unit_price, precision: 12, scale: 4
t.decimal :unit_tax, precision: 12, scale: 4
t.localized_string :part
t.localized_string :description
end
def buyer(t)
t.string :name
t.string :contact
t.string :email, limit: 100
t.string :phone, limit: 30
t.string :fax, limit: 30
%w[billing_ shipping_].each do |type|
t.string :"#{type}address1", limit: 150
t.string :"#{type}address2", limit: 150
t.string :"#{type}city", limit: 150
t.string :"#{type}state", limit: 150
t.string :"#{type}country", limit: 2
t.string :"#{type}post_code", limit: 20
end
end
create_record_table :products, with_l10n: true do |t|
product t
t.localized_string :category
t.localized_string :long_description, limit: 0x10000
t.decimal :stock, precision: 12, scale: 4
t.string :stock_text
t.integer :length
t.integer :height
t.integer :width
t.decimal :weight, precision: 14, scale: 3
t.boolean :show_on_website
end
create_record_table :categories, with_l10n: true, tree: true do |t|
t.localized_string :name
end
create_record_table :buyers, origin_key: :nf_code do |t|
buyer t
t.binary :pin, limit: 255
t.boolean :website_access
t.boolean :allow_products
t.boolean :restrict_products
end
create_record_table :orders, sendable: true do |t|
t.string :nf_code
buyer t
t.string :buyer_reference
t.string :currency_code, limit: 3
t.string :shipping_method
t.decimal :shipping_price, precision: 12, scale: 4
t.decimal :shipping_tax, precision: 12, scale: 4
t.string :shipping_account
t.string :shipping_password
t.string :payment_method
t.boolean :payment_received
t.string :payment_reference
t.string :payment_error_code, limit: 16
t.string :comment, limit: 0x10000
end
create_record_table :order_lines, writable: true do |t|
t.string :product_id
product t
t.references :order
t.decimal :quantity, precision: 12, scale: 4
t.string :comment, limit: 0x10000
end
create_file_table :images do |t|
t.float :focus_point_top
t.float :focus_point_left
t.integer :width
t.integer :height
end
create_file_table :attachments
create_relation_table :products, :images
create_relation_table :products, :categories
create_relation_table :products, :attachments
create_relation_table :products, :buyers
end
|