Symfony2 Doctrine Migration failed

Viewed 1962

I'm new to Symfony. In Symfony 2.8.3 project I created mirgation file using

php app/console doctrine:migrations:generate

But when I put some code in up() and down() methods and try to run

php app/console doctrine:migrations:migrate

I get mistake:

Migration 20160314161511 failed during Pre-Checks. Error Notice: Undefined offset: 1

[Symfony\Component\Debug\Exception\ContextErrorException] Notice: Undefined offset: 1

I tried to put different code by using "clear" SQL or via scheme, even left up/down methods with only //comments. But still no success. DoctrineMigrationsBundle was installed and registered in AppKernel.php. Here's the code of my aim mirgation:

namespace Application\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20160314161511 extends AbstractMigration
{
    /**
     * @param Schema $schema
     */
    public function up(Schema $schema)
    {
        $this->addSql(
            "CREATE TABLE tblProductData (
            intProductDataId int(10) unsigned NOT NULL AUTO_INCREMENT,
              strProductName varchar(50) NOT NULL,
              strProductDesc varchar(255) NOT NULL,
              strProductCode varchar(10) NOT NULL,
              dtmAdded datetime DEFAULT NULL,
              dtmDiscontinued datetime DEFAULT NULL,
              stmTimestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
              PRIMARY KEY (intProductDataId),
              UNIQUE KEY (strProductCode)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Stores product data'"
        );

    }

    /**
     * @param Schema $schema
     */
    public function down(Schema $schema)
    {
        $this->addSql(
            'DROP TABLE tblProductData'
        );

    }
}

Here is the doctrine_migrations section of my config.yml:

doctrine_migrations:
    dir_name: "%kernel.root_dir%/DoctrineMigrations"
    namespace: Application\Migrations
    table_name: migration_versions
    name: Application Migrations

doctrine section of config.yml I left with default value

When I use

php app/console doctrine:migrations:status

I get Available Migrations: 1 and New Migrations: 1

1 Answers
Related