Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5394 by Travin
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:
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()
    {
    }
}

Then, i created ext\my-ext\lib\custom\setup\default\schema\subscription.php
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;
        },
    ),
);

Finally, i run artisan aimeos:setup

The result is:
Code: Select allCreating SUBSCRIPTIONS tables
  Using tables from subscription.php

But there are no one new table at db. :(
What did I forget to do?
Thanks