/** * @param \Notadd\Foundation\Database\Schema\Blueprint $blueprint * @param \Illuminate\Support\Fluent $command * @param \Notadd\Foundation\Database\Connection $connection * @return array * @throws \Doctrine\DBAL\DBALException */ public function compileChange(Blueprint $blueprint, Fluent $command, Connection $connection) { if (!$connection->isDoctrineAvailable()) { throw new RuntimeException(sprintf('Changing columns for table "%s" requires Doctrine DBAL; install "doctrine/dbal".', $blueprint->getTable())); } $schema = $connection->getDoctrineSchemaManager(); $tableDiff = $this->getChangedDiff($blueprint, $schema); if ($tableDiff !== false) { return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff); } return []; }
/** * @param \Notadd\Foundation\Database\Schema\Blueprint $blueprint * @param \Illuminate\Support\Fluent $command * @param \Notadd\Foundation\Database\Connection $connection * @return array */ public function compileDropColumn(Blueprint $blueprint, Fluent $command, Connection $connection) { $schema = $connection->getDoctrineSchemaManager(); $tableDiff = $this->getDoctrineTableDiff($blueprint, $schema); foreach ($command->columns as $name) { $column = $connection->getDoctrineColumn($blueprint->getTable(), $name); $tableDiff->removedColumns[$name] = $column; } return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff); }