This repository has been archived by the owner on Dec 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathInstallSchema.php
146 lines (141 loc) · 4.07 KB
/
InstallSchema.php
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
<?php
/**
* Fontis Australia Extension for Magento 2
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/osl-3.0.php
*
* @category Fontis
* @package Fontis_Australia
* @copyright Copyright (c) 2017 Fontis Pty. Ltd. (https://www.fontis.com.au)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Fontis\Australia\Setup;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class InstallSchema implements InstallSchemaInterface
{
/**
* Install event handler
*
* @param SchemaSetupInterface $installer
* @param ModuleContextInterface $context
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$this->createParcelTable($setup);
$setup->endSetup();
}
/**
* Create australia_eparcel schema
*
* @param SchemaSetupInterface $setup
*/
public function createParcelTable(SchemaSetupInterface $setup)
{
$table = $setup->getConnection()->newTable(
$setup->getTable('australia_eparcel')
)
->addColumn(
'pk',
Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Entity Id'
)
->addColumn(
'website_id',
Table::TYPE_SMALLINT,
11,
['unsigned' => true, 'default' => '0'],
'Website Id'
)
->addColumn(
'dest_country_id',
Table::TYPE_TEXT,
4,
['nullable' => false, 'default' => '0'],
'Country Id'
)
->addColumn(
'dest_region_id',
Table::TYPE_INTEGER,
10,
['nullable' => false, 'default' => '0'],
'Region Id'
)
->addColumn(
'dest_zip',
Table::TYPE_TEXT,
10,
['nullable' => false, 'default' => ''],
'Zip Id'
)
->addColumn(
'condition_name',
Table::TYPE_TEXT,
20,
['nullable' => false, 'default' => '']
)
->addColumn(
'condition_from_value',
Table::TYPE_DECIMAL,
[12,4],
['nullable' => false, 'default' => '0.0000']
)
->addColumn(
'condition_to_value',
Table::TYPE_DECIMAL,
[12,4],
['nullable' => false, 'default' => '0.0000']
)
->addColumn(
'price',
Table::TYPE_DECIMAL,
[12,4],
['nullable' => false, 'default' => '0.0000']
)
->addColumn(
'price_per_kg',
Table::TYPE_DECIMAL,
[12,4],
['nullable' => false, 'default' => '0.0000']
)
->addColumn(
'cost',
Table::TYPE_DECIMAL,
[12,4],
['nullable' => false, 'default' => '0.0000']
)
->addColumn(
'delivery_type',
Table::TYPE_TEXT,
50,
['nullable' => false, 'default' => '']
)
->addColumn(
'charge_code_individual',
Table::TYPE_TEXT,
50,
['nullable' => false, 'default' => '']
)
->addColumn(
'charge_code_business',
Table::TYPE_TEXT,
50,
['nullable' => false, 'default' => '']
)
->addIndex(
'dest_country',
['website_id', 'dest_country_id', 'dest_region_id', 'dest_zip', 'condition_name', 'condition_to_value', 'delivery_type']
);
$setup->getConnection()->createTable($table);
}
}