|
|
@@ -144,7 +144,7 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@inheritDoc}
|
|
|
*/
|
|
|
- public function convertColumnDescription(Table $table, $row)
|
|
|
+ public function convertColumnDescription(TableSchema $schema, $row)
|
|
|
{
|
|
|
$field = $this->_convertColumn(
|
|
|
$row['type'],
|
|
|
@@ -167,7 +167,7 @@ class SqlserverSchema extends BaseSchema
|
|
|
'default' => $this->_defaultValue($row['default']),
|
|
|
'collate' => $row['collation_name'],
|
|
|
];
|
|
|
- $table->addColumn($row['name'], $field);
|
|
|
+ $schema->addColumn($row['name'], $field);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -220,7 +220,7 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@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 @@ class SqlserverSchema extends BaseSchema
|
|
|
}
|
|
|
|
|
|
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 @@ class SqlserverSchema extends BaseSchema
|
|
|
}
|
|
|
|
|
|
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 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@inheritDoc}
|
|
|
*/
|
|
|
- public function convertForeignKeyDescription(Table $table, $row)
|
|
|
+ public function convertForeignKeyDescription(TableSchema $schema, $row)
|
|
|
{
|
|
|
$data = [
|
|
|
'type' => Table::CONSTRAINT_FOREIGN,
|
|
|
@@ -291,7 +291,7 @@ class SqlserverSchema extends BaseSchema
|
|
|
'delete' => $this->_convertOnClause($row['delete_type']),
|
|
|
];
|
|
|
$name = $row['foreign_key_name'];
|
|
|
- $table->addConstraint($name, $data);
|
|
|
+ $schema->addConstraint($name, $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -326,7 +326,7 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@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 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@inheritDoc}
|
|
|
*/
|
|
|
- public function addConstraintSql(Table $schema)
|
|
|
+ public function addConstraintSql(TableSchema $schema)
|
|
|
{
|
|
|
$sqlPattern = 'ALTER TABLE %s ADD %s;';
|
|
|
$sql = [];
|
|
|
@@ -437,15 +437,15 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@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 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@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,7 +468,7 @@ class SqlserverSchema extends BaseSchema
|
|
|
return sprintf(
|
|
|
'CREATE INDEX %s ON %s (%s)',
|
|
|
$this->_driver->quoteIdentifier($name),
|
|
|
- $this->_driver->quoteIdentifier($table->name()),
|
|
|
+ $this->_driver->quoteIdentifier($schema->name()),
|
|
|
implode(', ', $columns)
|
|
|
);
|
|
|
}
|
|
|
@@ -476,7 +476,7 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@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 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@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 @@ class SqlserverSchema extends BaseSchema
|
|
|
/**
|
|
|
* {@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()
|
|
|
);
|
|
|
}
|
|
|
}
|