From 2a56362fef239879acc8c79d3277dfe472123ca6 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Fri, 16 Oct 2020 14:54:28 +0200 Subject: [PATCH 1/3] Refactor schema setup into db_schema.xml and db_schema_whitelist.json --- Setup/InstallSchema.php | 137 ----------------------------------- etc/db_schema.xml | 28 +++++++ etc/db_schema_whitelist.json | 34 +++++++++ etc/module.xml | 2 +- 4 files changed, 63 insertions(+), 138 deletions(-) delete mode 100644 Setup/InstallSchema.php create mode 100644 etc/db_schema.xml create mode 100644 etc/db_schema_whitelist.json diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php deleted file mode 100644 index 1adfdd4..0000000 --- a/Setup/InstallSchema.php +++ /dev/null @@ -1,137 +0,0 @@ -startSetup(); - if (!$installer->tableExists('wuunder_shipment')) { - $table = $installer->getConnection()->newTable( - $installer->getTable('wuunder_shipment') - ) - ->addColumn( - 'shipment_id', - Table::TYPE_INTEGER, - null, - [ - 'identity' => true, - 'nullable' => false, - 'primary' => true, - 'unsigned' => true, - ], - 'Shipment ID' - ) - ->addColumn( - 'order_id', - Table::TYPE_INTEGER, - null, - ['nullable => false'], - 'Shipment Name' - ) - ->addColumn( - 'label_id', - Table::TYPE_INTEGER, - null, - ['nullable => true'], - 'Shipment label id' - ) - ->addColumn( - 'label_url', - Table::TYPE_TEXT, - '64k', - ['nullable => true'], - 'Shipment label url' - ) - ->addColumn( - 'tt_url', - Table::TYPE_TEXT, - '64k', - ['nullable => true'], - 'Shipment T&T url' - ) - ->addColumn( - 'booking_url', - Table::TYPE_TEXT, - '64k', - ['nullable => true'], - 'Shipment booking url' - ) - ->addColumn( - 'booking_token', - Table::TYPE_TEXT, - '64k', - ['nullable => false'], - 'Shipment booking token' - ) - ->setComment('Wuunder shipment table'); - $installer->getConnection()->createTable($table); - } - - if (!$installer->tableExists('wuunder_quote_id')) { - $table = $installer->getConnection()->newTable( - $installer->getTable('wuunder_quote_id') - ) - ->addColumn( - 'id', - Table::TYPE_INTEGER, - null, - [ - 'identity' => true, - 'nullable' => false, - 'primary' => true, - 'unsigned' => true, - ], - 'ID' - ) - ->addColumn( - 'quote_id', - Table::TYPE_INTEGER, - null, - ['nullable => false'], - 'Quote Info' - ) - ->addColumn( - 'parcelshop_id', - Table::TYPE_TEXT, - null, - ['nullable => true'], - 'Parcelshop id' - ) - ->setComment('Wuunder shipment table'); - $installer->getConnection()->createTable($table); - - } - - $orderTable = 'sales_order'; - - //Order table - $setup->getConnection() - ->addColumn( - $setup->getTable($orderTable), - 'wuunder_parcelshop_id', - [ - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 255, - 'comment' =>'Custom Attribute' - ] - ); - - $setup->endSetup(); - } -} \ No newline at end of file diff --git a/etc/db_schema.xml b/etc/db_schema.xml new file mode 100644 index 0000000..cfc64b6 --- /dev/null +++ b/etc/db_schema.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + +
+
diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json new file mode 100644 index 0000000..5dbcb19 --- /dev/null +++ b/etc/db_schema_whitelist.json @@ -0,0 +1,34 @@ +{ + "wuunder_shipment": { + "column": { + "shipment_id": true, + "order_id": true, + "label_id": true, + "label_url": true, + "tt_url": true, + "booking_url": true, + "booking_token": true + }, + "index": { + "WUUNDER_SHIPMENT_ORDER_ID": true + }, + "constraint": { + "PRIMARY": true + } + }, + "wuunder_quote_id": { + "column": { + "id": true, + "quote_id": true, + "parcelshop_id": true + }, + "constraint": { + "PRIMARY": true + } + }, + "sales_order": { + "column": { + "wuunder_parcelshop_id": true + } + } +} \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index b5814ff..9b4940b 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,7 +1,7 @@ - + From aa37897a68f1a400db40dc33cfb06ca246182cd3 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Fri, 16 Oct 2020 14:54:42 +0200 Subject: [PATCH 2/3] Add index on wuunder_shipment.order_id --- etc/db_schema.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/etc/db_schema.xml b/etc/db_schema.xml index cfc64b6..6729f93 100644 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -11,6 +11,9 @@ + + + From bc593d9ce3024a6fa29073418929b33c13d9e89e Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Fri, 16 Oct 2020 14:58:02 +0200 Subject: [PATCH 3/3] Add EOF newline --- etc/db_schema_whitelist.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json index 5dbcb19..b6d04e8 100644 --- a/etc/db_schema_whitelist.json +++ b/etc/db_schema_whitelist.json @@ -31,4 +31,4 @@ "wuunder_parcelshop_id": true } } -} \ No newline at end of file +}