1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* CakePHPify : CakePHP Plugin for Shopify API Authentication |
4
|
|
|
* Copyright (c) Multidimension.al (http://multidimension.al) |
5
|
|
|
* Github : https://github.com/multidimension-al/cakephpify |
6
|
|
|
* |
7
|
|
|
* Licensed under The MIT License |
8
|
|
|
* For full copyright and license information, please see the LICENSE file |
9
|
|
|
* Redistributions of files must retain the above copyright notice. |
10
|
|
|
* |
11
|
|
|
* @copyright (c) Multidimension.al (http://multidimension.al) |
12
|
|
|
* @link https://github.com/multidimension-al/cakephpify CakePHPify Github |
13
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
use Migrations\AbstractMigration; |
17
|
|
|
|
18
|
|
|
class DatabaseV2 extends AbstractMigration |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @return void |
23
|
|
|
*/ |
24
|
|
|
public function up() |
25
|
|
|
{ |
26
|
|
|
$this->table('access_tokens') |
27
|
|
|
->addColumn( |
28
|
|
|
'shop_id', |
29
|
|
|
'integer', |
30
|
|
|
[ |
31
|
|
|
'default' => null, |
32
|
|
|
'limit' => 10, |
33
|
|
|
'null' => false, |
34
|
|
|
] |
35
|
|
|
) |
36
|
|
|
->addColumn( |
37
|
|
|
'api_key', |
38
|
|
|
'string', |
39
|
|
|
[ |
40
|
|
|
'default' => null, |
41
|
|
|
'limit' => 32, |
42
|
|
|
'null' => false, |
43
|
|
|
] |
44
|
|
|
) |
45
|
|
|
->addColumn( |
46
|
|
|
'token', |
47
|
|
|
'string', |
48
|
|
|
[ |
49
|
|
|
'default' => null, |
50
|
|
|
'limit' => 255, |
51
|
|
|
'null' => false, |
52
|
|
|
] |
53
|
|
|
) |
54
|
|
|
->addColumn( |
55
|
|
|
'created_at', |
56
|
|
|
'datetime', |
57
|
|
|
[ |
58
|
|
|
'default' => 'CURRENT_TIMESTAMP', |
59
|
|
|
'limit' => null, |
60
|
|
|
'null' => false, |
61
|
|
|
] |
62
|
|
|
) |
63
|
|
|
->addColumn( |
64
|
|
|
'updated_at', |
65
|
|
|
'datetime', |
66
|
|
|
[ |
67
|
|
|
'default' => 'CURRENT_TIMESTAMP', |
68
|
|
|
'limit' => null, |
69
|
|
|
'null' => false, |
70
|
|
|
] |
71
|
|
|
) |
72
|
|
|
->addColumn( |
73
|
|
|
'expired_at', |
74
|
|
|
'datetime', |
75
|
|
|
[ |
76
|
|
|
'default' => null, |
77
|
|
|
'limit' => null, |
78
|
|
|
'null' => true, |
79
|
|
|
] |
80
|
|
|
) |
81
|
|
|
->addIndex( |
82
|
|
|
[ |
83
|
|
|
'token', |
84
|
|
|
], |
85
|
|
|
['unique' => true] |
86
|
|
|
) |
87
|
|
|
->addIndex( |
88
|
|
|
[ |
89
|
|
|
'shop_id', |
90
|
|
|
] |
91
|
|
|
) |
92
|
|
|
->create(); |
93
|
|
|
|
94
|
|
|
$this->table('shops') |
95
|
|
|
->addColumn( |
96
|
|
|
'domain', |
97
|
|
|
'string', |
98
|
|
|
[ |
99
|
|
|
'default' => null, |
100
|
|
|
'limit' => 255, |
101
|
|
|
'null' => false, |
102
|
|
|
] |
103
|
|
|
) |
104
|
|
|
->addColumn( |
105
|
|
|
'name', |
106
|
|
|
'string', |
107
|
|
|
[ |
108
|
|
|
'default' => null, |
109
|
|
|
'limit' => 255, |
110
|
|
|
'null' => false, |
111
|
|
|
] |
112
|
|
|
) |
113
|
|
|
->addColumn( |
114
|
|
|
'email', |
115
|
|
|
'string', |
116
|
|
|
[ |
117
|
|
|
'default' => null, |
118
|
|
|
'limit' => 255, |
119
|
|
|
'null' => false, |
120
|
|
|
] |
121
|
|
|
) |
122
|
|
|
->addColumn( |
123
|
|
|
'shop_owner', |
124
|
|
|
'string', |
125
|
|
|
[ |
126
|
|
|
'default' => null, |
127
|
|
|
'limit' => 255, |
128
|
|
|
'null' => false, |
129
|
|
|
] |
130
|
|
|
) |
131
|
|
|
->addColumn( |
132
|
|
|
'address1', |
133
|
|
|
'string', |
134
|
|
|
[ |
135
|
|
|
'default' => null, |
136
|
|
|
'limit' => 255, |
137
|
|
|
'null' => false, |
138
|
|
|
] |
139
|
|
|
) |
140
|
|
|
->addColumn( |
141
|
|
|
'address2', |
142
|
|
|
'string', |
143
|
|
|
[ |
144
|
|
|
'default' => null, |
145
|
|
|
'limit' => 255, |
146
|
|
|
'null' => false, |
147
|
|
|
] |
148
|
|
|
) |
149
|
|
|
->addColumn( |
150
|
|
|
'city', |
151
|
|
|
'string', |
152
|
|
|
[ |
153
|
|
|
'default' => null, |
154
|
|
|
'limit' => 255, |
155
|
|
|
'null' => false, |
156
|
|
|
] |
157
|
|
|
) |
158
|
|
|
->addColumn( |
159
|
|
|
'province_code', |
160
|
|
|
'string', |
161
|
|
|
[ |
162
|
|
|
'default' => null, |
163
|
|
|
'limit' => 10, |
164
|
|
|
'null' => false, |
165
|
|
|
] |
166
|
|
|
) |
167
|
|
|
->addColumn( |
168
|
|
|
'province', |
169
|
|
|
'string', |
170
|
|
|
[ |
171
|
|
|
'default' => null, |
172
|
|
|
'limit' => 255, |
173
|
|
|
'null' => false, |
174
|
|
|
] |
175
|
|
|
) |
176
|
|
|
->addColumn( |
177
|
|
|
'zip', |
178
|
|
|
'string', |
179
|
|
|
[ |
180
|
|
|
'default' => null, |
181
|
|
|
'limit' => 10, |
182
|
|
|
'null' => false, |
183
|
|
|
] |
184
|
|
|
) |
185
|
|
|
->addColumn( |
186
|
|
|
'country', |
187
|
|
|
'string', |
188
|
|
|
[ |
189
|
|
|
'default' => null, |
190
|
|
|
'limit' => 2, |
191
|
|
|
'null' => false, |
192
|
|
|
] |
193
|
|
|
) |
194
|
|
|
->addColumn( |
195
|
|
|
'country_code', |
196
|
|
|
'string', |
197
|
|
|
[ |
198
|
|
|
'default' => null, |
199
|
|
|
'limit' => 2, |
200
|
|
|
'null' => false, |
201
|
|
|
] |
202
|
|
|
) |
203
|
|
|
->addColumn( |
204
|
|
|
'country_name', |
205
|
|
|
'string', |
206
|
|
|
[ |
207
|
|
|
'default' => null, |
208
|
|
|
'limit' => 255, |
209
|
|
|
'null' => false, |
210
|
|
|
] |
211
|
|
|
) |
212
|
|
|
->addColumn( |
213
|
|
|
'source', |
214
|
|
|
'string', |
215
|
|
|
[ |
216
|
|
|
'default' => null, |
217
|
|
|
'limit' => 255, |
218
|
|
|
'null' => true, |
219
|
|
|
] |
220
|
|
|
) |
221
|
|
|
->addColumn( |
222
|
|
|
'phone', |
223
|
|
|
'string', |
224
|
|
|
[ |
225
|
|
|
'default' => null, |
226
|
|
|
'limit' => 100, |
227
|
|
|
'null' => false, |
228
|
|
|
] |
229
|
|
|
) |
230
|
|
|
->addColumn( |
231
|
|
|
'created_at', |
232
|
|
|
'datetime', |
233
|
|
|
[ |
234
|
|
|
'default' => null, |
235
|
|
|
'limit' => null, |
236
|
|
|
'null' => false, |
237
|
|
|
] |
238
|
|
|
) |
239
|
|
|
->addColumn( |
240
|
|
|
'updated_at', |
241
|
|
|
'datetime', |
242
|
|
|
[ |
243
|
|
|
'default' => null, |
244
|
|
|
'limit' => null, |
245
|
|
|
'null' => false, |
246
|
|
|
] |
247
|
|
|
) |
248
|
|
|
->addColumn( |
249
|
|
|
'customer_email', |
250
|
|
|
'string', |
251
|
|
|
[ |
252
|
|
|
'default' => null, |
253
|
|
|
'limit' => 255, |
254
|
|
|
'null' => false, |
255
|
|
|
] |
256
|
|
|
) |
257
|
|
|
->addColumn( |
258
|
|
|
'latitude', |
259
|
|
|
'decimal', |
260
|
|
|
[ |
261
|
|
|
'default' => null, |
262
|
|
|
'null' => false, |
263
|
|
|
'precision' => 10, |
264
|
|
|
'scale' => 8, |
265
|
|
|
] |
266
|
|
|
) |
267
|
|
|
->addColumn( |
268
|
|
|
'longitude', |
269
|
|
|
'decimal', |
270
|
|
|
[ |
271
|
|
|
'default' => null, |
272
|
|
|
'null' => false, |
273
|
|
|
'precision' => 11, |
274
|
|
|
'scale' => 8, |
275
|
|
|
] |
276
|
|
|
) |
277
|
|
|
->addColumn( |
278
|
|
|
'primary_location_id', |
279
|
|
|
'integer', |
280
|
|
|
[ |
281
|
|
|
'default' => null, |
282
|
|
|
'limit' => 10, |
283
|
|
|
'null' => true, |
284
|
|
|
] |
285
|
|
|
) |
286
|
|
|
->addColumn( |
287
|
|
|
'primary_locale', |
288
|
|
|
'string', |
289
|
|
|
[ |
290
|
|
|
'default' => 'en', |
291
|
|
|
'limit' => 10, |
292
|
|
|
'null' => false, |
293
|
|
|
] |
294
|
|
|
) |
295
|
|
|
->addColumn( |
296
|
|
|
'currency', |
297
|
|
|
'string', |
298
|
|
|
[ |
299
|
|
|
'default' => 'USD', |
300
|
|
|
'limit' => 10, |
301
|
|
|
'null' => false, |
302
|
|
|
] |
303
|
|
|
) |
304
|
|
|
->addColumn( |
305
|
|
|
'iana_timezone', |
306
|
|
|
'string', |
307
|
|
|
[ |
308
|
|
|
'default' => null, |
309
|
|
|
'limit' => 255, |
310
|
|
|
'null' => false, |
311
|
|
|
] |
312
|
|
|
) |
313
|
|
|
->addColumn( |
314
|
|
|
'money_format', |
315
|
|
|
'string', |
316
|
|
|
[ |
317
|
|
|
'default' => '${{amount}}', |
318
|
|
|
'limit' => 255, |
319
|
|
|
'null' => false, |
320
|
|
|
] |
321
|
|
|
) |
322
|
|
|
->addColumn( |
323
|
|
|
'money_with_currency_format', |
324
|
|
|
'string', |
325
|
|
|
[ |
326
|
|
|
'default' => '${{amount}} USD', |
327
|
|
|
'limit' => 255, |
328
|
|
|
'null' => false, |
329
|
|
|
] |
330
|
|
|
) |
331
|
|
|
->addColumn( |
332
|
|
|
'taxes_included', |
333
|
|
|
'boolean', |
334
|
|
|
[ |
335
|
|
|
'default' => null, |
336
|
|
|
'limit' => null, |
337
|
|
|
'null' => true, |
338
|
|
|
] |
339
|
|
|
) |
340
|
|
|
->addColumn( |
341
|
|
|
'tax_shipping', |
342
|
|
|
'boolean', |
343
|
|
|
[ |
344
|
|
|
'default' => null, |
345
|
|
|
'limit' => null, |
346
|
|
|
'null' => true, |
347
|
|
|
] |
348
|
|
|
) |
349
|
|
|
->addColumn( |
350
|
|
|
'county_taxes', |
351
|
|
|
'boolean', |
352
|
|
|
[ |
353
|
|
|
'default' => null, |
354
|
|
|
'limit' => null, |
355
|
|
|
'null' => true, |
356
|
|
|
] |
357
|
|
|
) |
358
|
|
|
->addColumn( |
359
|
|
|
'plan_display_name', |
360
|
|
|
'string', |
361
|
|
|
[ |
362
|
|
|
'default' => null, |
363
|
|
|
'limit' => 255, |
364
|
|
|
'null' => false, |
365
|
|
|
] |
366
|
|
|
) |
367
|
|
|
->addColumn( |
368
|
|
|
'plan_name', |
369
|
|
|
'string', |
370
|
|
|
[ |
371
|
|
|
'default' => null, |
372
|
|
|
'limit' => 255, |
373
|
|
|
'null' => false, |
374
|
|
|
] |
375
|
|
|
) |
376
|
|
|
->addColumn( |
377
|
|
|
'has_discounts', |
378
|
|
|
'boolean', |
379
|
|
|
[ |
380
|
|
|
'default' => null, |
381
|
|
|
'limit' => null, |
382
|
|
|
'null' => true, |
383
|
|
|
] |
384
|
|
|
) |
385
|
|
|
->addColumn( |
386
|
|
|
'has_gift_cards', |
387
|
|
|
'boolean', |
388
|
|
|
[ |
389
|
|
|
'default' => null, |
390
|
|
|
'limit' => null, |
391
|
|
|
'null' => true, |
392
|
|
|
] |
393
|
|
|
) |
394
|
|
|
->addColumn( |
395
|
|
|
'myshopify_domain', |
396
|
|
|
'string', |
397
|
|
|
[ |
398
|
|
|
'default' => null, |
399
|
|
|
'limit' => 255, |
400
|
|
|
'null' => false, |
401
|
|
|
] |
402
|
|
|
) |
403
|
|
|
->addColumn( |
404
|
|
|
'google_apps_domain', |
405
|
|
|
'string', |
406
|
|
|
[ |
407
|
|
|
'default' => null, |
408
|
|
|
'limit' => 255, |
409
|
|
|
'null' => true, |
410
|
|
|
] |
411
|
|
|
) |
412
|
|
|
->addColumn( |
413
|
|
|
'google_apps_login_enabled', |
414
|
|
|
'string', |
415
|
|
|
[ |
416
|
|
|
'default' => null, |
417
|
|
|
'limit' => 255, |
418
|
|
|
'null' => true, |
419
|
|
|
] |
420
|
|
|
) |
421
|
|
|
->addColumn( |
422
|
|
|
'money_in_emails_format', |
423
|
|
|
'string', |
424
|
|
|
[ |
425
|
|
|
'default' => '${{amount}}', |
426
|
|
|
'limit' => 255, |
427
|
|
|
'null' => false, |
428
|
|
|
] |
429
|
|
|
) |
430
|
|
|
->addColumn( |
431
|
|
|
'money_with_currency_in_emails_format', |
432
|
|
|
'string', |
433
|
|
|
[ |
434
|
|
|
'default' => '${{amount}} USD', |
435
|
|
|
'limit' => 255, |
436
|
|
|
'null' => false, |
437
|
|
|
] |
438
|
|
|
) |
439
|
|
|
->addColumn( |
440
|
|
|
'eligible_for_payments', |
441
|
|
|
'boolean', |
442
|
|
|
[ |
443
|
|
|
'default' => null, |
444
|
|
|
'limit' => null, |
445
|
|
|
'null' => true, |
446
|
|
|
] |
447
|
|
|
) |
448
|
|
|
->addColumn( |
449
|
|
|
'requires_extra_payments_agreement', |
450
|
|
|
'boolean', |
451
|
|
|
[ |
452
|
|
|
'default' => null, |
453
|
|
|
'limit' => null, |
454
|
|
|
'null' => true, |
455
|
|
|
] |
456
|
|
|
) |
457
|
|
|
->addColumn( |
458
|
|
|
'password_enabled', |
459
|
|
|
'boolean', |
460
|
|
|
[ |
461
|
|
|
'default' => null, |
462
|
|
|
'limit' => null, |
463
|
|
|
'null' => true, |
464
|
|
|
] |
465
|
|
|
) |
466
|
|
|
->addColumn( |
467
|
|
|
'has_storefront', |
468
|
|
|
'boolean', |
469
|
|
|
[ |
470
|
|
|
'default' => null, |
471
|
|
|
'limit' => null, |
472
|
|
|
'null' => true, |
473
|
|
|
] |
474
|
|
|
) |
475
|
|
|
->addColumn( |
476
|
|
|
'eligible_for_card_reader_giveaway', |
477
|
|
|
'boolean', |
478
|
|
|
[ |
479
|
|
|
'default' => null, |
480
|
|
|
'limit' => null, |
481
|
|
|
'null' => true, |
482
|
|
|
] |
483
|
|
|
) |
484
|
|
|
->addColumn( |
485
|
|
|
'finances', |
486
|
|
|
'boolean', |
487
|
|
|
[ |
488
|
|
|
'default' => null, |
489
|
|
|
'limit' => null, |
490
|
|
|
'null' => true, |
491
|
|
|
] |
492
|
|
|
) |
493
|
|
|
->addColumn( |
494
|
|
|
'setup_required', |
495
|
|
|
'boolean', |
496
|
|
|
[ |
497
|
|
|
'default' => null, |
498
|
|
|
'limit' => null, |
499
|
|
|
'null' => true, |
500
|
|
|
] |
501
|
|
|
) |
502
|
|
|
->addColumn( |
503
|
|
|
'force_ssl', |
504
|
|
|
'boolean', |
505
|
|
|
[ |
506
|
|
|
'default' => null, |
507
|
|
|
'limit' => null, |
508
|
|
|
'null' => true, |
509
|
|
|
] |
510
|
|
|
) |
511
|
|
|
->addIndex( |
512
|
|
|
[ |
513
|
|
|
'domain', |
514
|
|
|
] |
515
|
|
|
) |
516
|
|
|
->create(); |
517
|
|
|
|
518
|
|
|
$this->table('access_tokens') |
519
|
|
|
->addForeignKey( |
520
|
|
|
'shop_id', |
521
|
|
|
'shops', |
522
|
|
|
'id', |
523
|
|
|
[ |
524
|
|
|
'update' => 'RESTRICT', |
525
|
|
|
'delete' => 'RESTRICT' |
526
|
|
|
] |
527
|
|
|
) |
528
|
|
|
->update(); |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
/** |
532
|
|
|
* @return void |
533
|
|
|
*/ |
534
|
|
|
public function down() |
535
|
|
|
{ |
536
|
|
|
$this->table('access_tokens') |
537
|
|
|
->dropForeignKey( |
538
|
|
|
'shop_id' |
539
|
|
|
); |
540
|
|
|
|
541
|
|
|
$this->dropTable('access_tokens'); |
542
|
|
|
$this->dropTable('shops'); |
543
|
|
|
} |
544
|
|
|
} |
545
|
|
|
|