public function testUpdatedColumnIndexFailed() { $migrations = ['IndexMigration', 'UpdatedColumnIndexMigration']; $migrationsToExecute = []; foreach ($migrations as $migration) { $migrationClass = 'RDV\\Bundle\\MigrationBundle\\Tests\\Unit\\Fixture\\TestPackage\\' . $migration; $migrationsToExecute[] = new MigrationState(new $migrationClass()); } $migrationsToExecute[] = new MigrationState(new Test1BundleInstallation()); $this->setExpectedException('\\RuntimeException', 'Failed migrations: RDV\\Bundle\\MigrationBundle\\Tests\\Unit\\Fixture\\TestPackage\\UpdatedColumnIndexMigration.'); $this->executor->executeUp($migrationsToExecute); $this->assertEquals('> RDV\\Bundle\\MigrationBundle\\Tests\\Unit\\Fixture\\TestPackage\\UpdatedColumnIndexMigration', $this->logger->getMessages()[2]); $this->assertEquals(' ERROR: Could not create index for column with length more than 255.' . ' Please correct "key" column length "index_table2" in table in' . ' "RDV\\Bundle\\MigrationBundle\\Tests\\Unit\\Fixture\\TestPackage\\UpdatedColumnIndexMigration" migration', $this->logger->getMessages()[3]); $this->assertEquals('> RDV\\Bundle\\MigrationBundle\\Tests\\Unit\\Fixture\\TestPackage\\Test1Bundle\\Migrations\\Schema' . '\\Test1BundleInstallation - skipped', $this->logger->getMessages()[4]); }
/** * {@inheritdoc} */ protected function checkColumnName($tableName, $columnName, Migration $migration) { parent::checkColumnName($tableName, $columnName, $migration); if (strlen($columnName) > $this->nameGenerator->getMaxIdentifierSize()) { throw new InvalidNameException(sprintf('Max column name length is %s. Please correct "%s:%s" column in "%s" migration', $this->nameGenerator->getMaxIdentifierSize(), $tableName, $columnName, get_class($migration))); } }