Skip to content
Permalink
Browse files

Switching alias with the new class name.

  • Loading branch information...
dereuromark committed Nov 13, 2016
1 parent 16fb484 commit f3b0c18d761c8e227b20cd6ccb31904251cc0b07
@@ -57,9 +57,9 @@ public function describeOptionsSql($tableName, $config)
/**
* {@inheritDoc}
*/
public function convertOptionsDescription(Table $table, $row)
public function convertOptionsDescription(TableSchema $schema, $row)
{
$table->options([
$schema->options([
'engine' => $row['Engine'],
'collation' => $row['Collation'],
]);
@@ -154,7 +154,7 @@ protected function _convertColumn($column)
/**
* {@inheritDoc}
*/
public function convertColumnDescription(Table $table, $row)
public function convertColumnDescription(TableSchema $schema, $row)
{
$field = $this->_convertColumn($row['Type']);
$field += [
@@ -166,13 +166,13 @@ public function convertColumnDescription(Table $table, $row)
if (isset($row['Extra']) && $row['Extra'] === 'auto_increment') {
$field['autoIncrement'] = true;
}
$table->addColumn($row['Field'], $field);
$schema->addColumn($row['Field'], $field);
}
/**
* {@inheritDoc}
*/
public function convertIndexDescription(Table $table, $row)
public function convertIndexDescription(TableSchema $schema, $row)
{
$type = null;
$columns = $length = [];
@@ -200,9 +200,9 @@ public function convertIndexDescription(Table $table, $row)
$type === Table::INDEX_FULLTEXT
);
if ($isIndex) {
$existing = $table->index($name);
$existing = $schema->index($name);
} else {
$existing = $table->constraint($name);
$existing = $schema->constraint($name);
}
// MySQL multi column indexes come back as multiple rows.
@@ -211,13 +211,13 @@ public function convertIndexDescription(Table $table, $row)
$length = array_merge($existing['length'], $length);
}
if ($isIndex) {
$table->addIndex($name, [
$schema->addIndex($name, [
'type' => $type,
'columns' => $columns,
'length' => $length
]);
} else {
$table->addConstraint($name, [
$schema->addConstraint($name, [
'type' => $type,
'columns' => $columns,
'length' => $length
@@ -244,7 +244,7 @@ public function describeForeignKeySql($tableName, $config)
/**
* {@inheritDoc}
*/
public function convertForeignKeyDescription(Table $table, $row)
public function convertForeignKeyDescription(TableSchema $schema, $row)
{
$data = [
'type' => Table::CONSTRAINT_FOREIGN,
@@ -254,21 +254,21 @@ public function convertForeignKeyDescription(Table $table, $row)
'delete' => $this->_convertOnClause($row['DELETE_RULE']),
];
$name = $row['CONSTRAINT_NAME'];
$table->addConstraint($name, $data);
$schema->addConstraint($name, $data);
}
/**
* {@inheritDoc}
*/
public function truncateTableSql(Table $table)
public function truncateTableSql(TableSchema $schema)
{
return [sprintf('TRUNCATE TABLE `%s`', $table->name())];
return [sprintf('TRUNCATE TABLE `%s`', $schema->name())];
}
/**
* {@inheritDoc}
*/
public function createTableSql(Table $schema, $columns, $constraints, $indexes)
public function createTableSql(TableSchema $schema, $columns, $constraints, $indexes)
{
$content = implode(",\n", array_merge($columns, $constraints, $indexes));
$temporary = $schema->temporary() ? ' TEMPORARY ' : ' ';
@@ -290,7 +290,7 @@ public function createTableSql(Table $schema, $columns, $constraints, $indexes)
/**
* {@inheritDoc}
*/
public function columnSql(Table $schema, $name)
public function columnSql(TableSchema $schema, $name)
{
$data = $schema->column($name);
$out = $this->_driver->quoteIdentifier($name);
@@ -382,7 +382,7 @@ public function columnSql(Table $schema, $name)
}
$addAutoIncrement = (
[$name] == (array)$schema->primaryKey() &&
!$schema->hasAutoIncrement()
!$schema->hasAutoincrement()
);
if (in_array($data['type'], ['integer', 'biginteger']) &&
($data['autoIncrement'] === true || $addAutoIncrement)
@@ -414,7 +414,7 @@ public function columnSql(Table $schema, $name)
/**
* {@inheritDoc}
*/
public function constraintSql(Table $schema, $name)
public function constraintSql(TableSchema $schema, $name)
{
$data = $schema->constraint($name);
if ($data['type'] === Table::CONSTRAINT_PRIMARY) {
@@ -441,7 +441,7 @@ public function constraintSql(Table $schema, $name)
/**
* {@inheritDoc}
*/
public function addConstraintSql(Table $schema)
public function addConstraintSql(TableSchema $schema)
{
$sqlPattern = 'ALTER TABLE %s ADD %s;';
$sql = [];
@@ -460,15 +460,15 @@ public function addConstraintSql(Table $schema)
/**
* {@inheritDoc}
*/
public function dropConstraintSql(Table $table)
public function dropConstraintSql(TableSchema $schema)
{
$sqlPattern = 'ALTER TABLE %s DROP FOREIGN KEY %s;';
$sql = [];
foreach ($table->constraints() as $name) {
$constraint = $table->constraint($name);
foreach ($schema->constraints() as $name) {
$constraint = $schema->constraint($name);
if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
$tableName = $this->_driver->quoteIdentifier($table->name());
$tableName = $this->_driver->quoteIdentifier($schema->name());
$constraintName = $this->_driver->quoteIdentifier($name);
$sql[] = sprintf($sqlPattern, $tableName, $constraintName);
}
@@ -480,9 +480,9 @@ public function dropConstraintSql(Table $table)
/**
* {@inheritDoc}
*/
public function indexSql(Table $table, $name)
public function indexSql(TableSchema $schema, $name)
{
$data = $table->index($name);
$data = $schema->index($name);
if ($data['type'] === Table::INDEX_INDEX) {
$out = 'KEY ';
}
@@ -338,7 +338,7 @@ protected function _convertOnClause($clause)
/**
* {@inheritDoc}
*/
public function columnSql(Table $schema, $name)
public function columnSql(TableSchema $schema, $name)
{
$data = $schema->column($name);
$out = $this->_driver->quoteIdentifier($name);
@@ -420,7 +420,7 @@ public function columnSql(Table $schema, $name)
/**
* {@inheritDoc}
*/
public function addConstraintSql(Table $schema)
public function addConstraintSql(TableSchema $schema)
{
$sqlPattern = 'ALTER TABLE %s ADD %s;';
$sql = [];
@@ -478,7 +478,7 @@ public function indexSql(TableSchema $schema, $name)
/**
* {@inheritDoc}
*/
public function constraintSql(Table $schema, $name)
public function constraintSql(TableSchema $schema, $name)
{
$data = $schema->constraint($name);
$out = 'CONSTRAINT ' . $this->_driver->quoteIdentifier($name);
@@ -144,7 +144,7 @@ protected function _convertColumn($col, $length = null, $precision = null, $scal
/**
* {@inheritDoc}
*/
public function convertColumnDescription(Table $table, $row)
public function convertColumnDescription(TableSchema $schema, $row)
{
$field = $this->_convertColumn(
$row['type'],
@@ -167,7 +167,7 @@ public function convertColumnDescription(Table $table, $row)
'default' => $this->_defaultValue($row['default']),
'collate' => $row['collation_name'],
];
$table->addColumn($row['name'], $field);
$schema->addColumn($row['name'], $field);
}
/**
@@ -220,7 +220,7 @@ public function describeIndexSql($tableName, $config)
/**
* {@inheritDoc}
*/
public function convertIndexDescription(Table $table, $row)
public function convertIndexDescription(TableSchema $schema, $row)
{
$type = Table::INDEX_INDEX;
$name = $row['index_name'];
@@ -232,9 +232,9 @@ public function convertIndexDescription(Table $table, $row)
}
if ($type === Table::INDEX_INDEX) {
$existing = $table->index($name);
$existing = $schema->index($name);
} else {
$existing = $table->constraint($name);
$existing = $schema->constraint($name);
}
$columns = [$row['column_name']];
@@ -243,14 +243,14 @@ public function convertIndexDescription(Table $table, $row)
}
if ($type === Table::CONSTRAINT_PRIMARY || $type === Table::CONSTRAINT_UNIQUE) {
$table->addConstraint($name, [
$schema->addConstraint($name, [
'type' => $type,
'columns' => $columns
]);
return;
}
$table->addIndex($name, [
$schema->addIndex($name, [
'type' => $type,
'columns' => $columns
]);
@@ -281,7 +281,7 @@ public function describeForeignKeySql($tableName, $config)
/**
* {@inheritDoc}
*/
public function convertForeignKeyDescription(Table $table, $row)
public function convertForeignKeyDescription(TableSchema $schema, $row)
{
$data = [
'type' => Table::CONSTRAINT_FOREIGN,
@@ -291,7 +291,7 @@ public function convertForeignKeyDescription(Table $table, $row)
'delete' => $this->_convertOnClause($row['delete_type']),
];
$name = $row['foreign_key_name'];
$table->addConstraint($name, $data);
$schema->addConstraint($name, $data);
}
/**
@@ -326,7 +326,7 @@ protected function _convertOnClause($clause)
/**
* {@inheritDoc}
*/
public function columnSql(Table $schema, $name)
public function columnSql(TableSchema $schema, $name)
{
$data = $schema->column($name);
$out = $this->_driver->quoteIdentifier($name);
@@ -418,7 +418,7 @@ public function columnSql(Table $schema, $name)
/**
* {@inheritDoc}
*/
public function addConstraintSql(Table $schema)
public function addConstraintSql(TableSchema $schema)
{
$sqlPattern = 'ALTER TABLE %s ADD %s;';
$sql = [];
@@ -437,15 +437,15 @@ public function addConstraintSql(Table $schema)
/**
* {@inheritDoc}
*/
public function dropConstraintSql(Table $table)
public function dropConstraintSql(TableSchema $schema)
{
$sqlPattern = 'ALTER TABLE %s DROP CONSTRAINT %s;';
$sql = [];
foreach ($table->constraints() as $name) {
$constraint = $table->constraint($name);
foreach ($schema->constraints() as $name) {
$constraint = $schema->constraint($name);
if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
$tableName = $this->_driver->quoteIdentifier($table->name());
$tableName = $this->_driver->quoteIdentifier($schema->name());
$constraintName = $this->_driver->quoteIdentifier($name);
$sql[] = sprintf($sqlPattern, $tableName, $constraintName);
}
@@ -457,9 +457,9 @@ public function dropConstraintSql(Table $table)
/**
* {@inheritDoc}
*/
public function indexSql(Table $table, $name)
public function indexSql(TableSchema $schema, $name)
{
$data = $table->index($name);
$data = $schema->index($name);
$columns = array_map(
[$this->_driver, 'quoteIdentifier'],
$data['columns']
@@ -468,15 +468,15 @@ public function indexSql(Table $table, $name)
return sprintf(
'CREATE INDEX %s ON %s (%s)',
$this->_driver->quoteIdentifier($name),
$this->_driver->quoteIdentifier($table->name()),
$this->_driver->quoteIdentifier($schema->name()),
implode(', ', $columns)
);
}
/**
* {@inheritDoc}
*/
public function constraintSql(Table $schema, $name)
public function constraintSql(TableSchema $schema, $name)
{
$data = $schema->constraint($name);
$out = 'CONSTRAINT ' . $this->_driver->quoteIdentifier($name);
@@ -520,7 +520,7 @@ protected function _keySql($prefix, $data)
/**
* {@inheritDoc}
*/
public function createTableSql(Table $schema, $columns, $constraints, $indexes)
public function createTableSql(TableSchema $schema, $columns, $constraints, $indexes)
{
$content = array_merge($columns, $constraints);
$content = implode(",\n", array_filter($content));
@@ -537,21 +537,21 @@ public function createTableSql(Table $schema, $columns, $constraints, $indexes)
/**
* {@inheritDoc}
*/
public function truncateTableSql(Table $table)
public function truncateTableSql(TableSchema $schema)
{
$name = $this->_driver->quoteIdentifier($table->name());
$name = $this->_driver->quoteIdentifier($schema->name());
$queries = [
sprintf('DELETE FROM %s', $name)
];
// Restart identity sequences
$pk = $table->primaryKey();
$pk = $schema->primaryKey();
if (count($pk) === 1) {
$column = $table->column($pk[0]);
$column = $schema->column($pk[0]);
if (in_array($column['type'], ['integer', 'biginteger'])) {
$queries[] = sprintf(
"DBCC CHECKIDENT('%s', RESEED, 0)",
$table->name()
$schema->name()
);
}
}

0 comments on commit f3b0c18

Please sign in to comment.
You can’t perform that action at this time.