Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Db/Action/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@

namespace Migrations\Db\Action;

use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

abstract class Action
{
/**
* @var \Migrations\Db\Table\Table
* @var \Migrations\Db\Table\TableMetadata
*/
protected Table $table;
protected TableMetadata $table;

/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table the Table to apply the action to
* @param \Migrations\Db\Table\TableMetadata $table the Table to apply the action to
*/
public function __construct(Table $table)
public function __construct(TableMetadata $table)
{
$this->table = $table;
}

/**
* The table this action will be applied to
*
* @return \Migrations\Db\Table\Table
* @return \Migrations\Db\Table\TableMetadata
*/
public function getTable(): Table
public function getTable(): TableMetadata
{
return $this->table;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Db/Action/AddColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Migrations\Db\Literal;
use Migrations\Db\Table\Column;
use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class AddColumn extends Action
{
Expand All @@ -24,10 +24,10 @@ class AddColumn extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table to add the column to
* @param \Migrations\Db\Table\TableMetadata $table The table to add the column to
* @param \Migrations\Db\Table\Column $column The column to add
*/
public function __construct(Table $table, Column $column)
public function __construct(TableMetadata $table, Column $column)
{
parent::__construct($table);
$this->column = $column;
Expand All @@ -36,13 +36,13 @@ public function __construct(Table $table, Column $column)
/**
* Returns a new AddColumn object after assembling the given commands
*
* @param \Migrations\Db\Table\Table $table The table to add the column to
* @param \Migrations\Db\Table\TableMetadata $table The table to add the column to
* @param string $columnName The column name
* @param string|\Migrations\Db\Literal $type The column type
* @param array<string, mixed> $options The column options
* @return self
*/
public static function build(Table $table, string $columnName, string|Literal $type, array $options = []): self
public static function build(TableMetadata $table, string $columnName, string|Literal $type, array $options = []): self
{
$column = new Column();
$column->setName($columnName);
Expand Down
22 changes: 14 additions & 8 deletions src/Db/Action/AddForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Migrations\Db\Action;

use Migrations\Db\Table\ForeignKey;
use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class AddForeignKey extends Action
{
Expand All @@ -23,10 +23,10 @@ class AddForeignKey extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table to add the foreign key to
* @param \Migrations\Db\Table\TableMetadata $table The table to add the foreign key to
* @param \Migrations\Db\Table\ForeignKey $fk The foreign key to add
*/
public function __construct(Table $table, ForeignKey $fk)
public function __construct(TableMetadata $table, ForeignKey $fk)
{
parent::__construct($table);
$this->foreignKey = $fk;
Expand All @@ -36,22 +36,28 @@ public function __construct(Table $table, ForeignKey $fk)
* Creates a new AddForeignKey object after building the foreign key with
* the passed attributes
*
* @param \Migrations\Db\Table\Table $table The table object to add the foreign key to
* @param \Migrations\Db\Table\TableMetadata $table The table object to add the foreign key to
* @param string|string[] $columns The columns for the foreign key
* @param \Migrations\Db\Table\Table|string $referencedTable The table the foreign key references
* @param \Migrations\Db\Table\TableMetadata|string $referencedTable The table the foreign key references
* @param string|string[] $referencedColumns The columns in the referenced table
* @param array<string, mixed> $options Extra options for the foreign key
* @param string|null $name The name of the foreign key
* @return self
*/
public static function build(Table $table, string|array $columns, Table|string $referencedTable, string|array $referencedColumns = ['id'], array $options = [], ?string $name = null): self
{
public static function build(
TableMetadata $table,
string|array $columns,
TableMetadata|string $referencedTable,
string|array $referencedColumns = ['id'],
array $options = [],
?string $name = null,
): self {
if (is_string($referencedColumns)) {
$referencedColumns = [$referencedColumns]; // str to array
}

if (is_string($referencedTable)) {
$referencedTable = new Table($referencedTable);
$referencedTable = new TableMetadata($referencedTable);
}

// Shimming old 4.x
Expand Down
10 changes: 5 additions & 5 deletions src/Db/Action/AddIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Migrations\Db\Action;

use Migrations\Db\Table\Index;
use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class AddIndex extends Action
{
Expand All @@ -23,10 +23,10 @@ class AddIndex extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table to add the index to
* @param \Migrations\Db\Table\TableMetadata $table The table to add the index to
* @param \Migrations\Db\Table\Index $index The index to be added
*/
public function __construct(Table $table, Index $index)
public function __construct(TableMetadata $table, Index $index)
{
parent::__construct($table);
$this->index = $index;
Expand All @@ -36,12 +36,12 @@ public function __construct(Table $table, Index $index)
* Creates a new AddIndex object after building the index object with the
* provided arguments
*
* @param \Migrations\Db\Table\Table $table The table to add the index to
* @param \Migrations\Db\Table\TableMetadata $table The table to add the index to
* @param string|string[]|\Migrations\Db\Table\Index $columns The columns to index
* @param array<string, mixed> $options Additional options for the index creation
* @return self
*/
public static function build(Table $table, string|array|Index $columns, array $options = []): self
public static function build(TableMetadata $table, string|array|Index $columns, array $options = []): self
{
// create a new index object if strings or an array of strings were supplied
if (!($columns instanceof Index)) {
Expand Down
10 changes: 5 additions & 5 deletions src/Db/Action/ChangeColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Migrations\Db\Literal;
use Migrations\Db\Table\Column;
use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class ChangeColumn extends Action
{
Expand All @@ -31,11 +31,11 @@ class ChangeColumn extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table to alter
* @param \Migrations\Db\Table\TableMetadata $table The table to alter
* @param string $columnName The name of the column to change
* @param \Migrations\Db\Table\Column $column The column definition
*/
public function __construct(Table $table, string $columnName, Column $column)
public function __construct(TableMetadata $table, string $columnName, Column $column)
{
parent::__construct($table);
$this->columnName = $columnName;
Expand All @@ -51,13 +51,13 @@ public function __construct(Table $table, string $columnName, Column $column)
* Creates a new ChangeColumn object after building the column definition
* out of the provided arguments
*
* @param \Migrations\Db\Table\Table $table The table to alter
* @param \Migrations\Db\Table\TableMetadata $table The table to alter
* @param string $columnName The name of the column to change
* @param string|\Migrations\Db\Literal $type The type of the column
* @param array<string, mixed> $options Additional options for the column
* @return self
*/
public static function build(Table $table, string $columnName, string|Literal $type, array $options = []): self
public static function build(TableMetadata $table, string $columnName, string|Literal $type, array $options = []): self
{
$column = new Column();
$column->setName($columnName);
Expand Down
6 changes: 3 additions & 3 deletions src/Db/Action/ChangeComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Migrations\Db\Action;

use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class ChangeComment extends Action
{
Expand All @@ -22,10 +22,10 @@ class ChangeComment extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table to be changed
* @param \Migrations\Db\Table\TableMetadata $table The table to be changed
* @param string|null $newComment The new comment for the table
*/
public function __construct(Table $table, ?string $newComment)
public function __construct(TableMetadata $table, ?string $newComment)
{
parent::__construct($table);
$this->newComment = $newComment;
Expand Down
6 changes: 3 additions & 3 deletions src/Db/Action/ChangePrimaryKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Migrations\Db\Action;

use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class ChangePrimaryKey extends Action
{
Expand All @@ -22,10 +22,10 @@ class ChangePrimaryKey extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table to be changed
* @param \Migrations\Db\Table\TableMetadata $table The table to be changed
* @param string|string[]|null $newColumns The new columns for the primary key
*/
public function __construct(Table $table, string|array|null $newColumns)
public function __construct(TableMetadata $table, string|array|null $newColumns)
{
parent::__construct($table);
$this->newColumns = $newColumns;
Expand Down
10 changes: 5 additions & 5 deletions src/Db/Action/DropForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Migrations\Db\Action;

use Migrations\Db\Table\ForeignKey;
use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class DropForeignKey extends Action
{
Expand All @@ -23,10 +23,10 @@ class DropForeignKey extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table to remove the constraint from
* @param \Migrations\Db\Table\TableMetadata $table The table to remove the constraint from
* @param \Migrations\Db\Table\ForeignKey $foreignKey The foreign key to remove
*/
public function __construct(Table $table, ForeignKey $foreignKey)
public function __construct(TableMetadata $table, ForeignKey $foreignKey)
{
parent::__construct($table);
$this->foreignKey = $foreignKey;
Expand All @@ -36,12 +36,12 @@ public function __construct(Table $table, ForeignKey $foreignKey)
* Creates a new DropForeignKey object after building the ForeignKey
* definition out of the passed arguments.
*
* @param \Migrations\Db\Table\Table $table The table to delete the foreign key from
* @param \Migrations\Db\Table\TableMetadata $table The table to delete the foreign key from
* @param string|string[] $columns The columns participating in the foreign key
* @param string|null $constraint The constraint name
* @return self
*/
public static function build(Table $table, string|array $columns, ?string $constraint = null): self
public static function build(TableMetadata $table, string|array $columns, ?string $constraint = null): self
{
if (is_string($columns)) {
$columns = [$columns];
Expand Down
14 changes: 7 additions & 7 deletions src/Db/Action/DropIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Migrations\Db\Action;

use Migrations\Db\Table\Index;
use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class DropIndex extends Action
{
Expand All @@ -23,10 +23,10 @@ class DropIndex extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table owning the index
* @param \Migrations\Db\Table\TableMetadata $table The table owning the index
* @param \Migrations\Db\Table\Index $index The index to be dropped
*/
public function __construct(Table $table, Index $index)
public function __construct(TableMetadata $table, Index $index)
{
parent::__construct($table);
$this->index = $index;
Expand All @@ -36,11 +36,11 @@ public function __construct(Table $table, Index $index)
* Creates a new DropIndex object after assembling the passed
* arguments.
*
* @param \Migrations\Db\Table\Table $table The table where the index is
* @param \Migrations\Db\Table\TableMetadata $table The table where the index is
* @param string[] $columns the indexed columns
* @return self
*/
public static function build(Table $table, array $columns = []): self
public static function build(TableMetadata $table, array $columns = []): self
{
$index = new Index();
$index->setColumns($columns);
Expand All @@ -52,11 +52,11 @@ public static function build(Table $table, array $columns = []): self
* Creates a new DropIndex when the name of the index to drop
* is known.
*
* @param \Migrations\Db\Table\Table $table The table where the index is
* @param \Migrations\Db\Table\TableMetadata $table The table where the index is
* @param string $name The name of the index
* @return self
*/
public static function buildFromName(Table $table, string $name): self
public static function buildFromName(TableMetadata $table, string $name): self
{
$index = new Index();
$index->setName($name);
Expand Down
10 changes: 5 additions & 5 deletions src/Db/Action/RemoveColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Migrations\Db\Action;

use Migrations\Db\Table\Column;
use Migrations\Db\Table\Table;
use Migrations\Db\Table\TableMetadata;

class RemoveColumn extends Action
{
Expand All @@ -23,10 +23,10 @@ class RemoveColumn extends Action
/**
* Constructor
*
* @param \Migrations\Db\Table\Table $table The table where the column is
* @param \Migrations\Db\Table\TableMetadata $table The table where the column is
* @param \Migrations\Db\Table\Column $column The column to be removed
*/
public function __construct(Table $table, Column $column)
public function __construct(TableMetadata $table, Column $column)
{
parent::__construct($table);
$this->column = $column;
Expand All @@ -36,11 +36,11 @@ public function __construct(Table $table, Column $column)
* Creates a new RemoveColumn object after assembling the
* passed arguments.
*
* @param \Migrations\Db\Table\Table $table The table where the column is
* @param \Migrations\Db\Table\TableMetadata $table The table where the column is
* @param string $columnName The name of the column to drop
* @return self
*/
public static function build(Table $table, string $columnName): self
public static function build(TableMetadata $table, string $columnName): self
{
$column = new Column();
$column->setName($columnName);
Expand Down
Loading
Loading