Aimeos Laravel Package - How to execute Setup tasks
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Aimeos Laravel Package - How to execute Setup tasks
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!
Re: Aimeos Laravel Package - How to execute Setup tasks
No, you don't need the "PriceAddProductionCost.php" file because it's only necessary if you need data migration. Schema changes are made depending on your price.php schema file by the TablesCreateMShop setup task.
You have to run "php artisan aimeos:setup" to update your database.
We are all volunteers helping others for free besides working on our own projects. If you need support within defined reaction time, please ask the Aimeos company for help: https://aimeos.com/support/
You have to run "php artisan aimeos:setup" to update your database.
We are all volunteers helping others for free besides working on our own projects. If you need support within defined reaction time, please ask the Aimeos company for help: https://aimeos.com/support/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Aimeos Laravel Package - How to execute Setup tasks
Thank you so much! I really appreciate your efforts.aimeos wrote:No, you don't need the "PriceAddProductionCost.php" file because it's only necessary if you need data migration. Schema changes are made depending on your price.php schema file by the TablesCreateMShop setup task.
You have to run "php artisan aimeos:setup" to update your database.
We are all volunteers helping others for free besides working on our own projects. If you need support within defined reaction time, please ask the Aimeos company for help: https://aimeos.com/support/