Skip to content

Commit

Permalink
Remove deprecated Table schema class usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Mar 19, 2018
1 parent 49624cf commit f466fa8
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/Database/Schema/SqlserverSchema.php
Expand Up @@ -230,16 +230,16 @@ public function describeIndexSql($tableName, $config)
*/
public function convertIndexDescription(TableSchema $schema, $row)
{
$type = Table::INDEX_INDEX;
$type = TableSchema::INDEX_INDEX;
$name = $row['index_name'];
if ($row['is_primary_key']) {
$name = $type = Table::CONSTRAINT_PRIMARY;
$name = $type = TableSchema::CONSTRAINT_PRIMARY;
}
if ($row['is_unique_constraint'] && $type === Table::INDEX_INDEX) {
$type = Table::CONSTRAINT_UNIQUE;
if ($row['is_unique_constraint'] && $type === TableSchema::INDEX_INDEX) {
$type = TableSchema::CONSTRAINT_UNIQUE;
}

if ($type === Table::INDEX_INDEX) {
if ($type === TableSchema::INDEX_INDEX) {
$existing = $schema->getIndex($name);
} else {
$existing = $schema->getConstraint($name);
Expand All @@ -250,7 +250,7 @@ public function convertIndexDescription(TableSchema $schema, $row)
$columns = array_merge($existing['columns'], $columns);
}

if ($type === Table::CONSTRAINT_PRIMARY || $type === Table::CONSTRAINT_UNIQUE) {
if ($type === TableSchema::CONSTRAINT_PRIMARY || $type === TableSchema::CONSTRAINT_UNIQUE) {
$schema->addConstraint($name, [
'type' => $type,
'columns' => $columns
Expand Down Expand Up @@ -292,7 +292,7 @@ public function describeForeignKeySql($tableName, $config)
public function convertForeignKeyDescription(TableSchema $schema, $row)
{
$data = [
'type' => Table::CONSTRAINT_FOREIGN,
'type' => TableSchema::CONSTRAINT_FOREIGN,
'columns' => [$row['column']],
'references' => [$row['reference_table'], $row['reference_column']],
'update' => $this->_convertOnClause($row['update_type']),
Expand All @@ -309,7 +309,7 @@ protected function _foreignOnClause($on)
{
$parent = parent::_foreignOnClause($on);

return $parent === 'RESTRICT' ? parent::_foreignOnClause(Table::ACTION_SET_NULL) : $parent;
return $parent === 'RESTRICT' ? parent::_foreignOnClause(TableSchema::ACTION_SET_NULL) : $parent;
}

/**
Expand All @@ -319,16 +319,16 @@ protected function _convertOnClause($clause)
{
switch ($clause) {
case 'NO_ACTION':
return Table::ACTION_NO_ACTION;
return TableSchema::ACTION_NO_ACTION;
case 'CASCADE':
return Table::ACTION_CASCADE;
return TableSchema::ACTION_CASCADE;
case 'SET_NULL':
return Table::ACTION_SET_NULL;
return TableSchema::ACTION_SET_NULL;
case 'SET_DEFAULT':
return Table::ACTION_SET_DEFAULT;
return TableSchema::ACTION_SET_DEFAULT;
}

return Table::ACTION_SET_NULL;
return TableSchema::ACTION_SET_NULL;
}

/**
Expand Down Expand Up @@ -365,22 +365,22 @@ public function columnSql(TableSchema $schema, $name)
}
}

if ($data['type'] === TableSchema::TYPE_TEXT && $data['length'] !== Table::LENGTH_TINY) {
if ($data['type'] === TableSchema::TYPE_TEXT && $data['length'] !== TableSchema::LENGTH_TINY) {
$out .= ' NVARCHAR(MAX)';
}

if ($data['type'] === TableSchema::TYPE_BINARY) {
$out .= ' VARBINARY';

if ($data['length'] !== Table::LENGTH_TINY) {
if ($data['length'] !== TableSchema::LENGTH_TINY) {
$out .= '(MAX)';
} else {
$out .= sprintf('(%s)', Table::LENGTH_TINY);
$out .= sprintf('(%s)', TableSchema::LENGTH_TINY);
}
}

if ($data['type'] === TableSchema::TYPE_STRING ||
($data['type'] === TableSchema::TYPE_TEXT && $data['length'] === Table::LENGTH_TINY)
($data['type'] === TableSchema::TYPE_TEXT && $data['length'] === TableSchema::LENGTH_TINY)
) {
$type = ' NVARCHAR';

Expand Down Expand Up @@ -439,7 +439,7 @@ public function addConstraintSql(TableSchema $schema)

foreach ($schema->constraints() as $name) {
$constraint = $schema->getConstraint($name);
if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
if ($constraint['type'] === TableSchema::CONSTRAINT_FOREIGN) {
$tableName = $this->_driver->quoteIdentifier($schema->name());
$sql[] = sprintf($sqlPattern, $tableName, $this->constraintSql($schema, $name));
}
Expand All @@ -458,7 +458,7 @@ public function dropConstraintSql(TableSchema $schema)

foreach ($schema->constraints() as $name) {
$constraint = $schema->getConstraint($name);
if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
if ($constraint['type'] === TableSchema::CONSTRAINT_FOREIGN) {
$tableName = $this->_driver->quoteIdentifier($schema->name());
$constraintName = $this->_driver->quoteIdentifier($name);
$sql[] = sprintf($sqlPattern, $tableName, $constraintName);
Expand Down Expand Up @@ -494,10 +494,10 @@ public function constraintSql(TableSchema $schema, $name)
{
$data = $schema->getConstraint($name);
$out = 'CONSTRAINT ' . $this->_driver->quoteIdentifier($name);
if ($data['type'] === Table::CONSTRAINT_PRIMARY) {
if ($data['type'] === TableSchema::CONSTRAINT_PRIMARY) {
$out = 'PRIMARY KEY';
}
if ($data['type'] === Table::CONSTRAINT_UNIQUE) {
if ($data['type'] === TableSchema::CONSTRAINT_UNIQUE) {
$out .= ' UNIQUE';
}

Expand All @@ -517,7 +517,7 @@ protected function _keySql($prefix, $data)
[$this->_driver, 'quoteIdentifier'],
$data['columns']
);
if ($data['type'] === Table::CONSTRAINT_FOREIGN) {
if ($data['type'] === TableSchema::CONSTRAINT_FOREIGN) {
return $prefix . sprintf(
' FOREIGN KEY (%s) REFERENCES %s (%s) ON UPDATE %s ON DELETE %s',
implode(', ', $columns),
Expand Down

0 comments on commit f466fa8

Please sign in to comment.