Skip to content
Permalink
Browse files

Remove deprecated Table schema class usage.

  • Loading branch information...
dereuromark committed Mar 19, 2018
1 parent 49624cf commit f466fa82ce556f4cc639c29ab1829c388ecba23d
Showing with 22 additions and 22 deletions.
  1. +22 −22 src/Database/Schema/SqlserverSchema.php
@@ -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);
@@ -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
@@ -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']),
@@ -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;
}
/**
@@ -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;
}
/**
@@ -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';
@@ -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));
}
@@ -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);
@@ -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';
}
@@ -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),

0 comments on commit f466fa8

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