Merge branch 'master' into fronkdev
This commit is contained in:
@@ -10,12 +10,14 @@ final class AddDescriptionToAssetManagement extends AbstractMigration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table('AssetManagement');
|
||||
$table->addColumn('description', 'text', [
|
||||
'null' => true,
|
||||
'after' => 'name',
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,8 +25,10 @@ final class AddDescriptionToAssetManagement extends AbstractMigration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table('AssetManagement');
|
||||
$table->removeColumn('description');
|
||||
$table->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ final class ModifyBorrowReasonInAssetManagementJournal extends AbstractMigration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table('AssetManagementJournal');
|
||||
$table->changeColumn('borrowReason', 'text', [
|
||||
'null' => true,
|
||||
@@ -17,6 +18,7 @@ final class ModifyBorrowReasonInAssetManagementJournal extends AbstractMigration
|
||||
'after' => 'returnDate',
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -24,6 +26,7 @@ final class ModifyBorrowReasonInAssetManagementJournal extends AbstractMigration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
// Reverting the changes made in the up() method.
|
||||
// This assumes the column was NOT NULL and had no comment previously.
|
||||
$table = $this->table('AssetManagementJournal');
|
||||
@@ -32,5 +35,6 @@ final class ModifyBorrowReasonInAssetManagementJournal extends AbstractMigration
|
||||
'comment' => 'Reason for borrowing the asset', // Set comment back to empty
|
||||
]);
|
||||
$table->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ final class AssetManagementSchemaV2 extends AbstractMigration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
// 1. Add columns to AssetManagement table
|
||||
$assetManagement = $this->table('AssetManagement');
|
||||
$assetManagement
|
||||
@@ -91,6 +92,7 @@ final class AssetManagementSchemaV2 extends AbstractMigration
|
||||
])
|
||||
->addIndex(['assetId'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +100,7 @@ final class AssetManagementSchemaV2 extends AbstractMigration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
// Remove columns from AssetManagement
|
||||
$this->table('AssetManagement')
|
||||
->removeColumn('imageId')
|
||||
@@ -111,5 +114,6 @@ final class AssetManagementSchemaV2 extends AbstractMigration
|
||||
|
||||
// Drop reservation table
|
||||
$this->table('AssetManagementReservation')->drop()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,150 +10,154 @@ final class WarehouseOfferVersioning extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// Use Phinx schema builder to create the WarehouseOfferClosingText table
|
||||
$this->table('WarehouseOfferClosingText', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'comment' => 'Stores standard closing text snippets for offers',
|
||||
])
|
||||
->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
||||
->addColumn('name', 'string', ['limit' => 255])
|
||||
->addColumn('text', 'text')
|
||||
->addColumn('createBy', 'integer')
|
||||
->addColumn('create', 'integer')
|
||||
->create();
|
||||
|
||||
// Use Phinx schema builder to create the WarehouseOfferJournal table
|
||||
$this->table('WarehouseOfferJournal', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'comment' => 'Journal for tracking actions on warehouse offers',
|
||||
])
|
||||
->addColumn('id', 'integer', ['identity' => true, 'signed' => false])
|
||||
->addColumn('offerId', 'integer', ['null' => true])
|
||||
->addColumn('fileIds', 'text', ['null' => true])
|
||||
->addColumn('message', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('create', 'integer', ['null' => true])
|
||||
->addColumn('createBy', 'integer', ['null' => true])
|
||||
->addIndex(['offerId'], ['name' => 'offerId'])
|
||||
->addIndex(['createBy'], ['name' => 'createBy'])
|
||||
->create();
|
||||
|
||||
// Use Phinx schema builder to add columns to the WarehouseOffer table
|
||||
$warehouseOffer = $this->table('WarehouseOffer');
|
||||
$warehouseOffer
|
||||
->addColumn('contactPersonEmail', 'string', ['limit' => 255, 'null' => true, 'after' => 'contactPerson'])
|
||||
->addColumn('lastSentDate', 'integer', ['null' => true, 'after' => 'status'])
|
||||
->addColumn('version', 'integer', ['default' => 1, 'after' => 'id'])
|
||||
->addColumn('history_id', 'integer', ['null' => true, 'after' => 'version'])
|
||||
->save();
|
||||
|
||||
// Use Phinx schema builder to add the 'data' column to WarehouseHistory
|
||||
$warehouseHistory = $this->table('WarehouseHistory');
|
||||
$warehouseHistory
|
||||
->addColumn('data', 'text', [
|
||||
'limit' => MysqlAdapter::TEXT_LONG,
|
||||
'null' => true,
|
||||
'after' => 'note',
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
// Use Phinx schema builder to create the WarehouseOfferClosingText table
|
||||
$this->table('WarehouseOfferClosingText', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci'
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'comment' => 'Stores standard closing text snippets for offers',
|
||||
])
|
||||
->save();
|
||||
->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
||||
->addColumn('name', 'string', ['limit' => 255])
|
||||
->addColumn('text', 'text')
|
||||
->addColumn('createBy', 'integer')
|
||||
->addColumn('create', 'integer')
|
||||
->create();
|
||||
|
||||
// Data migration steps remain as raw SQL execution due to their complexity.
|
||||
$this->execute("DELETE FROM `WarehouseHistory` WHERE `table` = 'WarehouseOffer';");
|
||||
// Use Phinx schema builder to create the WarehouseOfferJournal table
|
||||
$this->table('WarehouseOfferJournal', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'comment' => 'Journal for tracking actions on warehouse offers',
|
||||
])
|
||||
->addColumn('id', 'integer', ['identity' => true, 'signed' => false])
|
||||
->addColumn('offerId', 'integer', ['null' => true])
|
||||
->addColumn('fileIds', 'text', ['null' => true])
|
||||
->addColumn('message', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('create', 'integer', ['null' => true])
|
||||
->addColumn('createBy', 'integer', ['null' => true])
|
||||
->addIndex(['offerId'], ['name' => 'offerId'])
|
||||
->addIndex(['createBy'], ['name' => 'createBy'])
|
||||
->create();
|
||||
|
||||
// Create a baseline version history for all existing offers.
|
||||
$this->execute("
|
||||
INSERT INTO `WarehouseHistory` (`table`, `row_id`, `key`, `old_value`, `new_value`, `note`, `data`, `user_id`, `create`)
|
||||
SELECT
|
||||
'WarehouseOffer' AS `table`,
|
||||
wo.id AS `row_id`,
|
||||
'version' AS `key`,
|
||||
0 AS `old_value`,
|
||||
1 AS `new_value`,
|
||||
'Baseline Version 1 erstellt durch Migration.' AS `note`,
|
||||
JSON_OBJECT(
|
||||
'id', wo.id,
|
||||
'version', 1,
|
||||
'history_id', NULL,
|
||||
'offerNumber', wo.offerNumber,
|
||||
'reference', wo.reference,
|
||||
'customerNumber', wo.customerNumber,
|
||||
'customerName', wo.customerName,
|
||||
'contactPerson', wo.contactPerson,
|
||||
'contactPersonEmail', wo.contactPersonEmail,
|
||||
'customerStreet', wo.customerStreet,
|
||||
'customerCity', wo.customerCity,
|
||||
'customerZip', wo.customerZip,
|
||||
'customerVAT', wo.customerVAT,
|
||||
'editor', wo.editor,
|
||||
'purpose', wo.purpose,
|
||||
'positions', wo.positions,
|
||||
'alternativePositions', wo.alternativePositions,
|
||||
'totalDiscount', wo.totalDiscount,
|
||||
'paymentTerms', wo.paymentTerms,
|
||||
'deliveryTerms', wo.deliveryTerms,
|
||||
'closingText', wo.closingText,
|
||||
'notes', wo.notes,
|
||||
'status', wo.status,
|
||||
'lastSentDate', wo.lastSentDate,
|
||||
'totalAmount', wo.totalAmount,
|
||||
'create', wo.create,
|
||||
'createBy', wo.createBy
|
||||
) AS `data`,
|
||||
wo.createBy AS `user_id`,
|
||||
UNIX_TIMESTAMP() AS `create`
|
||||
FROM `WarehouseOffer` wo;
|
||||
");
|
||||
// Use Phinx schema builder to add columns to the WarehouseOffer table
|
||||
$warehouseOffer = $this->table('WarehouseOffer');
|
||||
$warehouseOffer
|
||||
->addColumn('contactPersonEmail', 'string', ['limit' => 255, 'null' => true, 'after' => 'contactPerson'])
|
||||
->addColumn('lastSentDate', 'integer', ['null' => true, 'after' => 'status'])
|
||||
->addColumn('version', 'integer', ['default' => 1, 'after' => 'id'])
|
||||
->addColumn('history_id', 'integer', ['null' => true, 'after' => 'version'])
|
||||
->save();
|
||||
|
||||
// Update the history_id in the WarehouseOffer table to link to the newly created history entry.
|
||||
$this->execute("
|
||||
UPDATE `WarehouseOffer` wo
|
||||
JOIN `WarehouseHistory` wh ON wo.id = wh.row_id
|
||||
SET wo.history_id = wh.id
|
||||
WHERE wh.`table` = 'WarehouseOffer' AND wh.new_value = 1 AND wh.note = 'Baseline Version 1 erstellt durch Migration.';
|
||||
");
|
||||
// Use Phinx schema builder to add the 'data' column to WarehouseHistory
|
||||
$warehouseHistory = $this->table('WarehouseHistory');
|
||||
$warehouseHistory
|
||||
->addColumn('data', 'text', [
|
||||
'limit' => MysqlAdapter::TEXT_LONG,
|
||||
'null' => true,
|
||||
'after' => 'note',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci'
|
||||
])
|
||||
->save();
|
||||
|
||||
// Data migration steps remain as raw SQL execution due to their complexity.
|
||||
$this->execute("DELETE FROM `WarehouseHistory` WHERE `table` = 'WarehouseOffer';");
|
||||
|
||||
// Create a baseline version history for all existing offers.
|
||||
$this->execute("
|
||||
INSERT INTO `WarehouseHistory` (`table`, `row_id`, `key`, `old_value`, `new_value`, `note`, `data`, `user_id`, `create`)
|
||||
SELECT
|
||||
'WarehouseOffer' AS `table`,
|
||||
wo.id AS `row_id`,
|
||||
'version' AS `key`,
|
||||
0 AS `old_value`,
|
||||
1 AS `new_value`,
|
||||
'Baseline Version 1 erstellt durch Migration.' AS `note`,
|
||||
JSON_OBJECT(
|
||||
'id', wo.id,
|
||||
'version', 1,
|
||||
'history_id', NULL,
|
||||
'offerNumber', wo.offerNumber,
|
||||
'reference', wo.reference,
|
||||
'customerNumber', wo.customerNumber,
|
||||
'customerName', wo.customerName,
|
||||
'contactPerson', wo.contactPerson,
|
||||
'contactPersonEmail', wo.contactPersonEmail,
|
||||
'customerStreet', wo.customerStreet,
|
||||
'customerCity', wo.customerCity,
|
||||
'customerZip', wo.customerZip,
|
||||
'customerVAT', wo.customerVAT,
|
||||
'editor', wo.editor,
|
||||
'purpose', wo.purpose,
|
||||
'positions', wo.positions,
|
||||
'alternativePositions', wo.alternativePositions,
|
||||
'totalDiscount', wo.totalDiscount,
|
||||
'paymentTerms', wo.paymentTerms,
|
||||
'deliveryTerms', wo.deliveryTerms,
|
||||
'closingText', wo.closingText,
|
||||
'notes', wo.notes,
|
||||
'status', wo.status,
|
||||
'lastSentDate', wo.lastSentDate,
|
||||
'totalAmount', wo.totalAmount,
|
||||
'create', wo.create,
|
||||
'createBy', wo.createBy
|
||||
) AS `data`,
|
||||
wo.createBy AS `user_id`,
|
||||
UNIX_TIMESTAMP() AS `create`
|
||||
FROM `WarehouseOffer` wo;
|
||||
");
|
||||
|
||||
// Update the history_id in the WarehouseOffer table to link to the newly created history entry.
|
||||
$this->execute("
|
||||
UPDATE `WarehouseOffer` wo
|
||||
JOIN `WarehouseHistory` wh ON wo.id = wh.row_id
|
||||
SET wo.history_id = wh.id
|
||||
WHERE wh.`table` = 'WarehouseOffer' AND wh.new_value = 1 AND wh.note = 'Baseline Version 1 erstellt durch Migration.';
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Clean up the history created by this migration
|
||||
$this->execute("DELETE FROM `WarehouseHistory` WHERE `note` = 'Baseline Version 1 erstellt durch Migration.' AND `table` = 'WarehouseOffer';");
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
// Clean up the history created by this migration
|
||||
$this->execute("DELETE FROM `WarehouseHistory` WHERE `note` = 'Baseline Version 1 erstellt durch Migration.' AND `table` = 'WarehouseOffer';");
|
||||
|
||||
// Revert changes to the WarehouseOffer table
|
||||
$warehouseOfferTable = $this->table('WarehouseOffer');
|
||||
if ($warehouseOfferTable->hasColumn('history_id')) {
|
||||
$warehouseOfferTable->removeColumn('history_id')->save();
|
||||
}
|
||||
if ($warehouseOfferTable->hasColumn('version')) {
|
||||
$warehouseOfferTable->removeColumn('version')->save();
|
||||
}
|
||||
if ($warehouseOfferTable->hasColumn('lastSentDate')) {
|
||||
$warehouseOfferTable->removeColumn('lastSentDate')->save();
|
||||
}
|
||||
if ($warehouseOfferTable->hasColumn('contactPersonEmail')) {
|
||||
$warehouseOfferTable->removeColumn('contactPersonEmail')->save();
|
||||
}
|
||||
// Revert changes to the WarehouseOffer table
|
||||
$warehouseOfferTable = $this->table('WarehouseOffer');
|
||||
if ($warehouseOfferTable->hasColumn('history_id')) {
|
||||
$warehouseOfferTable->removeColumn('history_id')->save();
|
||||
}
|
||||
if ($warehouseOfferTable->hasColumn('version')) {
|
||||
$warehouseOfferTable->removeColumn('version')->save();
|
||||
}
|
||||
if ($warehouseOfferTable->hasColumn('lastSentDate')) {
|
||||
$warehouseOfferTable->removeColumn('lastSentDate')->save();
|
||||
}
|
||||
if ($warehouseOfferTable->hasColumn('contactPersonEmail')) {
|
||||
$warehouseOfferTable->removeColumn('contactPersonEmail')->save();
|
||||
}
|
||||
|
||||
// Revert changes to the WarehouseHistory table
|
||||
$warehouseHistoryTable = $this->table('WarehouseHistory');
|
||||
if ($warehouseHistoryTable->hasColumn('data')) {
|
||||
$warehouseHistoryTable->removeColumn('data')->save();
|
||||
}
|
||||
// Revert changes to the WarehouseHistory table
|
||||
$warehouseHistoryTable = $this->table('WarehouseHistory');
|
||||
if ($warehouseHistoryTable->hasColumn('data')) {
|
||||
$warehouseHistoryTable->removeColumn('data')->save();
|
||||
}
|
||||
|
||||
// Drop the newly created tables
|
||||
if ($this->hasTable('WarehouseOfferJournal')) {
|
||||
$this->table('WarehouseOfferJournal')->drop()->save();
|
||||
}
|
||||
if ($this->hasTable('WarehouseOfferClosingText')) {
|
||||
$this->table('WarehouseOfferClosingText')->drop()->save();
|
||||
// Drop the newly created tables
|
||||
if ($this->hasTable('WarehouseOfferJournal')) {
|
||||
$this->table('WarehouseOfferJournal')->drop()->save();
|
||||
}
|
||||
if ($this->hasTable('WarehouseOfferClosingText')) {
|
||||
$this->table('WarehouseOfferClosingText')->drop()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ShopAndOrderAddressEnhancements extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$eShopOrder = $this->table('WarehouseEShopOrder');
|
||||
$eShopOrder
|
||||
->addColumn('addressId', 'integer', [
|
||||
'null' => true,
|
||||
'after' => 'createBy'
|
||||
])
|
||||
->addIndex(['addressId'], ['name' => 'idx_addressId'])
|
||||
->save();
|
||||
|
||||
$this->execute("UPDATE `WarehouseEShopOrder` SET `addressId` = 209 WHERE `addressId` IS NULL");
|
||||
|
||||
$article = $this->table('WarehouseArticle');
|
||||
$article
|
||||
->addColumn('isSbidiShop', 'integer', [
|
||||
'default' => 0,
|
||||
'after' => 'isEShop'
|
||||
])
|
||||
->addColumn('isSbidiShopHide', 'integer', [
|
||||
'default' => 0,
|
||||
'after' => 'isSbidiShop'
|
||||
])
|
||||
->addIndex(['isEShop'], ['name' => 'idx_isEShop'])
|
||||
->addIndex(['isEShopHide'], ['name' => 'idx_isEShopHide'])
|
||||
->addIndex(['isSbidiShop'], ['name' => 'idx_isSbidiShop'])
|
||||
->addIndex(['isSbidiShopHide'], ['name' => 'idx_isSbidiShopHide'])
|
||||
->save();
|
||||
|
||||
$this->execute("UPDATE `WarehouseArticle` SET `isSbidiShop` = 0, `isSbidiShopHide` = 0 WHERE `isSbidiShop` IS NULL");
|
||||
|
||||
$articlePacket = $this->table('WarehouseArticlePacket');
|
||||
$articlePacket
|
||||
->addColumn('isEShop', 'integer', [
|
||||
'default' => 0,
|
||||
'after' => 'calculatedSellPrice'
|
||||
])
|
||||
->addColumn('isEShopHide', 'integer', [
|
||||
'default' => 0,
|
||||
'after' => 'isEShop'
|
||||
])
|
||||
->addColumn('isSbidiShop', 'integer', [
|
||||
'default' => 0,
|
||||
'after' => 'isEShopHide'
|
||||
])
|
||||
->addColumn('isSbidiShopHide', 'integer', [
|
||||
'default' => 0,
|
||||
'after' => 'isSbidiShop'
|
||||
])
|
||||
->addIndex(['isEShop'], ['name' => 'idx_isEShop_packet'])
|
||||
->addIndex(['isEShopHide'], ['name' => 'idx_isEShopHide_packet'])
|
||||
->addIndex(['isSbidiShop'], ['name' => 'idx_isSbidiShop_packet'])
|
||||
->addIndex(['isSbidiShopHide'], ['name' => 'idx_isSbidiShopHide_packet'])
|
||||
->save();
|
||||
|
||||
$this->execute("
|
||||
UPDATE `WarehouseArticlePacket`
|
||||
SET `isEShop` = 1, `isEShopHide` = 0, `isSbidiShop` = 0, `isSbidiShopHide` = 0
|
||||
WHERE `isEShop` IS NULL
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$articlePacket = $this->table('WarehouseArticlePacket');
|
||||
$articlePacket
|
||||
->removeColumn('isSbidiShopHide')
|
||||
->removeColumn('isSbidiShop')
|
||||
->removeColumn('isEShopHide')
|
||||
->removeColumn('isEShop')
|
||||
->save();
|
||||
|
||||
$article = $this->table('WarehouseArticle');
|
||||
$article
|
||||
->removeColumn('isSbidiShopHide')
|
||||
->removeColumn('isSbidiShop')
|
||||
->save();
|
||||
|
||||
$article
|
||||
->removeIndexByName('idx_isEShop')
|
||||
->removeIndexByName('idx_isEShopHide')
|
||||
->removeIndexByName('idx_isSbidiShop')
|
||||
->removeIndexByName('idx_isSbidiShopHide')
|
||||
->save();
|
||||
|
||||
$eShopOrder = $this->table('WarehouseEShopOrder');
|
||||
$eShopOrder
|
||||
->removeColumn('addressId')
|
||||
->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CpeprovAddNewIndexes extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if ($this->getEnvironment() == 'thetool') {
|
||||
$orderProduct = $this->table('OrderProduct');
|
||||
$orderProduct->addIndex('product_id', ['name' => 'idx_product_id'])
|
||||
->addIndex('termination_id', ['name' => 'idx_termination_id'])
|
||||
->save();
|
||||
|
||||
$product = $this->table('Product');
|
||||
$product->addIndex('producttech_id', ['name' => 'idx_producttech_id'])
|
||||
->save();
|
||||
|
||||
$productAttribute = $this->table('ProductAttribute');
|
||||
$productAttribute->addIndex('producttechattribute_id', ['name' => 'idx_producttechattribute_id'])
|
||||
->save();
|
||||
|
||||
$termination = $this->table('Termination');
|
||||
$termination->addIndex('status_id', ['name' => 'idx_status_id'])
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if ($this->getEnvironment() == 'thetool') {
|
||||
$orderProduct = $this->table('OrderProduct');
|
||||
$orderProduct->removeIndexByName('idx_product_id')
|
||||
->removeIndexByName('idx_termination_id')
|
||||
->save();
|
||||
|
||||
$product = $this->table('Product');
|
||||
$product->removeIndexByName('idx_producttech_id')
|
||||
->save();
|
||||
|
||||
$productAttribute = $this->table('ProductAttribute');
|
||||
$productAttribute->removeIndexByName('idx_producttechattribute_id')
|
||||
->save();
|
||||
|
||||
$termination = $this->table('Termination');
|
||||
$termination->removeIndexByName('idx_status_id')
|
||||
->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateRmlWorkorderTables extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$this->execute('DROP TABLE IF EXISTS `RMLWorkorderDocumentation`');
|
||||
$this->execute('DROP TABLE IF EXISTS `RMLWorkorderCompany`');
|
||||
$this->execute('DROP TABLE IF EXISTS `RMLWorkorder`');
|
||||
|
||||
$workorder = $this->table('RMLWorkorder', ['id' => false, 'primary_key' => ['id']]);
|
||||
$workorder->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
||||
->addColumn('preorderId', 'integer', ['null' => false])
|
||||
->addColumn('companyId', 'integer', ['null' => true])
|
||||
->addColumn('status', 'string', ['limit' => 50, 'null' => false, 'default' => 'new'])
|
||||
->addColumn('assignmentDate', 'integer', ['null' => true])
|
||||
->addColumn('deadlineDate', 'integer', ['null' => true])
|
||||
->addColumn('appointmentDate', 'integer', ['null' => true])
|
||||
->addColumn('create', 'integer', ['null' => false])
|
||||
->addColumn('createBy', 'integer', ['null' => false])
|
||||
->addIndex(['preorderId'], ['name' => 'preorderId_idx'])
|
||||
->addIndex(['companyId'], ['name' => 'companyId_idx'])
|
||||
->addIndex(['status'], ['name' => 'status_idx'])
|
||||
->create();
|
||||
|
||||
$company = $this->table('RMLWorkorderCompany', ['id' => false, 'primary_key' => ['id']]);
|
||||
$company->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
||||
->addColumn('addressId', 'integer', ['null' => false])
|
||||
->addColumn('name', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('create', 'integer', ['null' => false])
|
||||
->addColumn('createBy', 'integer', ['null' => false])
|
||||
->create();
|
||||
|
||||
$documentation = $this->table('RMLWorkorderDocumentation', ['id' => false, 'primary_key' => ['id']]);
|
||||
$documentation->addColumn('id', 'integer', ['identity' => true, 'signed' => true])
|
||||
->addColumn('workorderId', 'integer', ['null' => false])
|
||||
->addColumn('fileId', 'integer', ['null' => false])
|
||||
->addColumn('description', 'text', ['null' => true])
|
||||
->addColumn('documentType', 'string', ['limit' => 100, 'null' => false])
|
||||
->addColumn('create', 'integer', ['null' => false])
|
||||
->addColumn('createBy', 'integer', ['null' => false])
|
||||
->addIndex(['workorderId'], ['name' => 'workorderId_idx'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$this->table('RMLWorkorderDocumentation')->drop()->save();
|
||||
$this->table('RMLWorkorderCompany')->drop()->save();
|
||||
$this->table('RMLWorkorder')->drop()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user