-
Notifications
You must be signed in to change notification settings - Fork 2
/
migration.rb
348 lines (313 loc) · 6.12 KB
/
migration.rb
1
2
3
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# encoding: utf-8
#创建Admin表
class AddAdmin < ActiveRecord::Migration
def self.up
create_table :admins do |t|
t.string :adminname
t.string :adminpwd
end
end
def self.down
drop_table :admins
end
end
if not Admin.table_exists?
AddAdmin.up
end
#创建User表
class AddUser < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :login_id
t.string :password
t.string :real_name
t.string :ceilphone
t.string :qq
t.string :address
t.string :gender
t.string :email
t.string :privilege
t.string :use_flag
t.string :last_login
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :users
end
end
if not User.table_exists?
AddUser.up
end
#create TypeOne
class AddTypeOne < ActiveRecord::Migration
def self.up
create_table :type_ones do |t|
t.string :name
t.string :use_flag
t.string :type_no
t.string :name_s
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :type_ones
end
end
if not TypeOne.table_exists?
AddTypeOne.up
end
#create TypeTwo
class AddTypeTwo < ActiveRecord::Migration
def self.up
create_table :type_twos do |t|
t.string :name
t.string :type_no
t.string :name_s
t.string :type_one_id
t.string :use_flag
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :type_twos
end
end
if not TypeTwo.table_exists?
AddTypeTwo.up
end
#create TypeThree
class AddTypeThree < ActiveRecord::Migration
def self.up
create_table :type_threes do |t|
t.string :name
t.string :type_no
t.string :name_s
t.integer :type_one_id
t.string :type_one_no
t.string :type_one_name
t.integer :type_two_id
t.string :type_two_name
t.string :type_two_no
t.string :use_flag
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :type_threes
end
end
if not TypeThree.table_exists?
AddTypeThree.up
end
#create suppliers
class AddSupplier < ActiveRecord::Migration
def self.up
create_table :suppliers do |t|
t.string :name
t.string :name_s
t.string :address
t.string :telphone
t.string :ceilphone
t.string :fax
t.string :remark
t.string :supp_flag
t.string :use_flag
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :suppliers
end
end
if not Supplier.table_exists?
AddSupplier.up
end
#create shevles
class AddShevle < ActiveRecord::Migration
def self.up
create_table :shevles do |t|
t.string :name
t.string :no
t.string :shevle_type
t.string :remark
t.string :spec
t.string :use_flag
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :shevles
end
end
if not Shevle.table_exists?
AddShevle.up
end
#create goods
class AddGood < ActiveRecord::Migration
def self.up
create_table :goods do |t|
t.string :no
t.string :spec
t.string :name
t.string :name_s
t.string :picture
t.string :barcode
t.string :unit
t.integer :unit_price
t.integer :price
t.string :area
t.string :produce_date
t.string :valildity_date
t.string :shevle_id
t.integer :shevle_least
t.integer :shevle_most
t.integer :stock_most
t.integer :stock_least
t.string :supplier_id
t.string :supplier_name
t.integer :type_one_id
t.integer :type_two_id
t.integer :type_three_id
t.string :use_flag
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :goods
end
end
if not Good.table_exists?
AddGood.up
end
#create purchase
class AddPurchase < ActiveRecord::Migration
def self.up
create_table :purchases do |t|
t.string :no
t.integer :good_id
t.integer :type_one_id
t.integer :type_two_id
t.integer :type_three_id
t.string :good_name
t.string :good_unit
t.string :pur_count
t.string :pur_date
t.string :pur_id
t.string :unit
t.integer :unit_price
t.string :supplier_id
t.string :supplier_name
t.string :enforce_code
t.string :check_flag
t.string :remark
t.string :use_flag
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :purchases
end
end
if not Purchase.table_exists?
AddPurchase.up
end
#create inventory
class AddInventory < ActiveRecord::Migration
def self.up
create_table :inventorys do |t|
t.integer :purchase_id
t.string :purchase_no
t.integer :good_id
t.integer :type_one_id
t.integer :type_two_id
t.integer :type_three_id
t.string :good_name
t.string :good_barcode
t.string :good_unit
t.string :unit_price
t.integer :quantity
t.string :arrival_date
t.string :produce_date
t.string :expiry_date
t.string :supplier_id
t.string :supplier_name
t.string :enforce_code
t.string :check_flag
t.string :remark
t.string :use_flag
t.string :main_flag
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :inventorys
end
end
if not Inventory.table_exists?
AddInventory.up
end
#create inventory
class AddInventoryMX < ActiveRecord::Migration
def self.up
create_table :inventorys_mx do |t|
t.integer :purchase_id
t.string :purchase_no
t.integer :good_id
t.integer :type_one_id
t.integer :type_two_id
t.integer :type_three_id
t.string :good_name
t.string :good_barcode
t.string :good_unit
t.string :unit_price
t.integer :quantity
t.string :arrival_date
t.string :produce_date
t.string :expiry_date
t.string :supplier_id
t.string :supplier_name
t.string :enforce_code
t.string :reason_flag
t.string :use_flag
t.string :main_flag
t.string :add_id
t.string :add_date
t.string :upd_id
t.string :upd_date
end
end
def self.down
drop_table :inventorys_mx
end
end
if not InventoryMX.table_exists?
AddInventoryMX.up
end