Create setup task
Posted: 12 Jan 2018, 13:08
Hey
I'm creating new Setup Task according to https://aimeos.org/docs/Developers/Library/Setup_tasks/.
First of all, I created ext\my-ext\lib\custom\setup\SubscriptionAddTables.php:
Then, i created ext\my-ext\lib\custom\setup\default\schema\subscription.php
Finally, i run artisan aimeos:setup
The result is:
But there are no one new table at db.
What did I forget to do?
Thanks
I'm creating new Setup Task according to https://aimeos.org/docs/Developers/Library/Setup_tasks/.
First of all, I created ext\my-ext\lib\custom\setup\SubscriptionAddTables.php:
Code: Select all
<?php
namespace Aimeos\MW\Setup\Task;
class SubscriptionAddTables extends TablesCreateMShop
{
/**
* Returns the list of task names which this task depends on.
*
* @return string[] List of task names
*/
public function getPreDependencies()
{
return array( 'TablesCreateMShop' );
}
/**
* Returns the list of task names which depends on this task.
*
* @return string[] List of task names
*/
public function getPostDependencies()
{
}
/**
* Updates the schema and migrates the data
*/
public function migrate()
{
$this->msg( 'Creating SUBSCRIPTIONS tables', 0 );
$this->status( '' );
//die;
$ds = DIRECTORY_SEPARATOR;
$files = array( 'db-product' => __DIR__ . $ds . 'default' . $ds . 'schema' . $ds . 'subscription.php' );
$this->setupSchema( $files );
}
/**
* Undo all schema changes and migrate data back
*/
public function rollback()
{
}
/**
* Cleans up old data required for roll back
*/
public function clean()
{
}
}
Code: Select all
<?php
return array(
'table' => array(
'mshop_subscription' => function ( \Doctrine\DBAL\Schema\Schema $schema ) {
$table = $schema->createTable( 'mshop_subscription' );
$table->addColumn( 'id', 'integer', array( 'autoincrement' => true ) );
$table->addColumn( 'siteid', 'integer', array() );
$table->addColumn( 'myvalue', 'string', array( 'length' => 255, 'notnull' => false ) );
$table->addColumn( 'mtime', 'datetime', array() );
$table->addColumn( 'ctime', 'datetime', array() );
$table->addColumn( 'editor', 'string', array( 'length' => 255 ) );
//$table->setPrimaryKey( array( 'id' ), 'pk_msattmy_id' );
//$table->addUniqueIndex( array( 'siteid', 'myvalue' ), 'unq_msattmy_sid_myval' );
return $schema;
},
),
);
The result is:
Code: Select all
Creating SUBSCRIPTIONS tables
Using tables from subscription.php
What did I forget to do?
Thanks