Get the Doctrine DBAL schema manager for the connection.
public getDoctrineSchemaManager ( ) : Doctrine\DBAL\Schema\AbstractSchemaManager | ||
return | Doctrine\DBAL\Schema\AbstractSchemaManager |
/** * Compile a rename column command. * * @param \Illuminate\Database\Schema\Blueprint $blueprint * @param \Illuminate\Support\Fluent $command * @param \Illuminate\Database\Connection $connection * @return array */ public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection) { $schema = $connection->getDoctrineSchemaManager(); $column = $connection->getDoctrineColumn($blueprint->getTable(), $command->from); $tableDiff = $this->getRenamedDiff($blueprint, $command, $column, $schema); return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff); }
/** * Compile a drop column command. * * @param \Illuminate\Database\Schema\Blueprint $blueprint * @param \Illuminate\Support\Fluent $command * @param \Illuminate\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); }
/** * Compile a change column command into a series of SQL statements. * * @param \Illuminate\Database\Schema\Blueprint $blueprint * @param \Illuminate\Support\Fluent $command * @param \Illuminate\Database\Connection $connection * @return array */ 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 []; }
/** * Compile a change column command into a series of SQL statements. * * @param \Illuminate\Database\Schema\Blueprint $blueprint * @param \Illuminate\Support\Fluent $command * @param \Illuminate\Database\Connection $connection * @return array */ public function compileChange(Blueprint $blueprint, Fluent $command, Connection $connection) { $schema = $connection->getDoctrineSchemaManager(); $tableDiff = $this->getChangedDiff($blueprint, $schema); if ($tableDiff !== false) { return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff); } return []; }
/** * Constructor. * * @param \Illuminate\Database\Connection $connection * @return void */ public function __construct(Connection $connection) { $this->connection = $connection; $this->schemaManager = $connection->getDoctrineSchemaManager(); $this->platform = $this->schemaManager->getDatabasePlatform(); }
/** * @param string $table * @return array */ protected function getColumnSchemas($table) { $columns = $this->connection->getDoctrineSchemaManager(); return $columns->listTableColumns($table); }
/** * Determine if the given table has a given column. * * @param string $table * @param string $column * @return bool */ public function hasColumn($table, $column) { $schema = $this->connection->getDoctrineSchemaManager(); $columns = array_keys(array_change_key_case($schema->listTableColumns($table))); return in_array(strtolower($column), $columns); }
/** * Determine if the given table has a given column. * * @param string $table * @param string $column * @return bool */ public function hasColumn($table, $column) { $schema = $this->connection->getDoctrineSchemaManager(); return in_array($column, array_keys($schema->listTableColumns($table))); }