Aimeos Laravel Package - How to execute Setup tasks
Posted: 29 Mar 2018, 10:43
Laravel: 5.6
Aimeos: 2017.x
PHP: 7.x
Environment: Linux
Hi,
I need to add additional field in "mshop_price" table. The field name is "productioncost." So, I studied following link:
https://aimeos.org/docs/Developers/Library/Setup_tasks
and did what is asked. I created "price.php" file in "./ext/myextension/lib/custom/setup/default/schema" directory. Below is the code of "price.php."
https://aimeos.org/docs/Developers/Libr ... ema_update
Then I created a Basic Setup Task after reading the following URL:
https://aimeos.org/docs/Developers/Libr ... sks/Basics
I created "PriceAddProductionCost.php" file inside "./ext/myextension/lib/custom/setup" directory. Below is the code:
Now, I have three questions.
1. Is Setup file "PriceAddProductionCost.php" necessary to modify table?
2. If Setup file is necessary then kindly guide me if my created file "PriceAddProductionCost.php" is OK?
3. And last question, how to execute Setup file?
Please, reply ASAP!
Thanks!
Aimeos: 2017.x
PHP: 7.x
Environment: Linux
Hi,
I need to add additional field in "mshop_price" table. The field name is "productioncost." So, I studied following link:
https://aimeos.org/docs/Developers/Library/Setup_tasks
and did what is asked. I created "price.php" file in "./ext/myextension/lib/custom/setup/default/schema" directory. Below is the code of "price.php."
https://aimeos.org/docs/Developers/Libr ... ema_update
Code: Select all
return array(
'table' => array(
'mshop_price' => function ( \Doctrine\DBAL\Schema\Schema $schema ) {
// $table = $schema->createTable( 'mshop_price' );
$table = $schema->getTable( 'mshop_price' );
$table->addColumn( 'productioncost', 'decimal', array( 'precision' => 12, 'scale' => 2 ) );
$table->addIndex( array( 'siteid', 'domain', 'productioncost' ), 'idx_mspri_sid_dom_productioncost' );
return $schema;
}
)
);
https://aimeos.org/docs/Developers/Libr ... sks/Basics
I created "PriceAddProductionCost.php" file inside "./ext/myextension/lib/custom/setup" directory. Below is the code:
Code: Select all
namespace Aimeos\MW\Setup\Task;
class PriceAddProductionCost extends \Aimeos\MW\Setup\Task\Base
{
private $mysql = array(
'ALTER TABLE "mshop_price" ADD "productioncost" DECIMAL(12,2) NOT NULL AFTER "value"'
);
/**
* Returns the list of task names which this task depends on.
*
* @return string[] List of task names
*/
public function getPreDependencies()
{
return array( 'TablesCreateMShop', 'MShopAddLocaleData' );
}
/**
* Returns the list of task names which depends on this task.
*
* @return string[] List of task names
*/
public function getPostDependencies()
{
return [];
}
/**
* Updates the schema and migrates the data
*/
public function migrate()
{
}
/**
* Undo all schema changes and migrate data back
*/
public function rollback()
{
}
/**
* Cleans up old data required for roll back
*/
public function clean()
{
}
}
1. Is Setup file "PriceAddProductionCost.php" necessary to modify table?
2. If Setup file is necessary then kindly guide me if my created file "PriceAddProductionCost.php" is OK?
3. And last question, how to execute Setup file?
Please, reply ASAP!
Thanks!