/** * @param Schema $targetSchema * @param \Doctrine\DBAL\Connection $connection * @return \Doctrine\DBAL\Schema\SchemaDiff */ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { $platform = $connection->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer'); $platform->registerDoctrineTypeMapping('smallint unsigned', 'integer'); return parent::getDiff($targetSchema, $connection); }
/** * @param Schema $targetSchema * @param \Doctrine\DBAL\Connection $connection * @return \Doctrine\DBAL\Schema\SchemaDiff */ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { $schemaDiff = parent::getDiff($targetSchema, $connection); // identifiers need to be quoted for mysql foreach ($schemaDiff->changedTables as $tableDiff) { $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name); foreach ($tableDiff->changedColumns as $column) { $column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName); } } return $schemaDiff; }
/** * Speed up migration test by disabling autocommit and unique indexes check * * @param \Doctrine\DBAL\Schema\Table $table * @throws \OC\DB\MigrationException */ protected function checkTableMigrate(Table $table) { $this->connection->exec('SET autocommit=0'); $this->connection->exec('SET unique_checks=0'); try { parent::checkTableMigrate($table); } catch (\Exception $e) { $this->connection->exec('SET unique_checks=1'); $this->connection->exec('SET autocommit=1'); throw new MigrationException($table->getName(), $e->getMessage()); } $this->connection->exec('SET unique_checks=1'); $this->connection->exec('SET autocommit=1'); }
/** * @param Schema $targetSchema * @param \Doctrine\DBAL\Connection $connection * @return \Doctrine\DBAL\Schema\SchemaDiff */ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { $platform = $connection->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('enum', 'string'); $platform->registerDoctrineTypeMapping('bit', 'string'); $schemaDiff = parent::getDiff($targetSchema, $connection); // identifiers need to be quoted for mysql foreach ($schemaDiff->changedTables as $tableDiff) { $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name); foreach ($tableDiff->changedColumns as $column) { $column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName); } } return $schemaDiff; }
/** * @param Schema $targetSchema * @param \Doctrine\DBAL\Connection $connection * @return \Doctrine\DBAL\Schema\SchemaDiff */ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { $platform = $connection->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer'); $platform->registerDoctrineTypeMapping('smallint unsigned', 'integer'); $platform->registerDoctrineTypeMapping('varchar ', 'string'); // with sqlite autoincrement columns is of type integer foreach ($targetSchema->getTables() as $table) { foreach ($table->getColumns() as $column) { if ($column->getType() instanceof BigIntType && $column->getAutoincrement()) { $column->setType(Type::getType('integer')); } } } return parent::getDiff($targetSchema, $connection); }
/** * @param Schema $targetSchema * @param \Doctrine\DBAL\Connection $connection * @return \Doctrine\DBAL\Schema\SchemaDiff */ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { $schemaDiff = parent::getDiff($targetSchema, $connection); foreach ($schemaDiff->changedTables as $tableDiff) { // fix default value in brackets - pg 9.4 is returning a negative default value in () // see https://github.com/doctrine/dbal/issues/2427 foreach ($tableDiff->changedColumns as $column) { $column->changedProperties = array_filter($column->changedProperties, function ($changedProperties) use($column) { if ($changedProperties !== 'default') { return true; } $fromDefault = $column->fromColumn->getDefault(); $toDefault = $column->column->getDefault(); $fromDefault = trim($fromDefault, "()"); // by intention usage of != return $fromDefault != $toDefault; }); } } return $schemaDiff; }