Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fad7c5c
feat(database): implement migration column types and table structure
barbosa89 Oct 30, 2025
8c9f497
refactor: rename FloatColumn to Floating
barbosa89 Oct 30, 2025
dcdf195
refactor: update parameter types to use nullable syntax in Table clas…
barbosa89 Oct 30, 2025
aa32f5b
feat(database): introduce BigInteger and UnsignedInteger column types…
barbosa89 Oct 30, 2025
c99f969
refactor(database): simplify column constructors by removing redundan…
barbosa89 Oct 30, 2025
c194dea
refactor(database): integrate HasSign trait into Decimal, Integer, an…
barbosa89 Oct 30, 2025
fd3cd3d
refactor(database): remove signed parameters from integer, bigInteger…
barbosa89 Oct 30, 2025
704355a
refactor(database): remove signed parameter from Decimal constructor,…
barbosa89 Oct 30, 2025
7cabf09
refactor(tests): update column options in TableTest to align with new…
barbosa89 Oct 30, 2025
3bad8c6
refactor(database): add unsignedInteger and unsignedBigInteger method…
barbosa89 Oct 30, 2025
dcaf2c3
feat(database): add UnsignedDecimal, UnsignedFloat, and UnsignedSmall…
barbosa89 Oct 30, 2025
cd4b55e
feat(database): add adapter handling methods to Column class and upda…
barbosa89 Oct 30, 2025
34dab2a
feat(database): add new column types (Bit, Blob, Char, Cidr, Double, …
barbosa89 Oct 31, 2025
9e051ab
refactor(database): remove constructor from column classes to simplif…
barbosa89 Oct 31, 2025
196db15
refactor: split table class
barbosa89 Oct 31, 2025
a37b6a8
tests: add migration columns tests
barbosa89 Nov 2, 2025
7550232
refactor(database): change visibility of addColumnWithAdapter method …
barbosa89 Nov 2, 2025
5ddc36d
tests: bit, blob and char columns
barbosa89 Nov 2, 2025
3c17d2e
tests: add column positioning and collation features for MySQL and Po…
barbosa89 Nov 2, 2025
8ad4226
tests: add migration test for returning new table instance
barbosa89 Nov 4, 2025
284674a
tests: enhance adapter change test for column types in TableTest
barbosa89 Nov 4, 2025
2dc11c6
feat(database): add ULID column support and corresponding tests
barbosa89 Nov 4, 2025
acb2a75
refactor(Table): remove destructor for column saving logic
barbosa89 Nov 4, 2025
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
9 changes: 8 additions & 1 deletion src/Database/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@

namespace Phenix\Database;

use Phenix\Database\Migrations\Table;
use Phinx\Migration\AbstractMigration;

abstract class Migration extends AbstractMigration
{
// ..
public function table(string $tableName, array $options = []): Table
{
$table = new Table($tableName, $options, $this->getAdapter());
$this->tables[] = $table;

return $table;
}
}
26 changes: 26 additions & 0 deletions src/Database/Migrations/Columns/BigInteger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace Phenix\Database\Migrations\Columns;

use Phenix\Database\Migrations\Columns\Concerns\HasSign;

class BigInteger extends UnsignedBigInteger
{
use HasSign;

public function __construct(
protected string $name,
bool $identity = false,
) {
parent::__construct($name, $identity);

$this->options['signed'] = true;
}

public function getType(): string
{
return 'biginteger';
}
}
31 changes: 31 additions & 0 deletions src/Database/Migrations/Columns/Binary.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Phenix\Database\Migrations\Columns;

class Binary extends Column
{
public function __construct(
protected string $name,
int|null $limit = null
) {
parent::__construct($name);

if ($limit) {
$this->options['limit'] = $limit;
}
}

public function getType(): string
{
return 'binary';
}

public function default(string $value): static
{
$this->options['default'] = $value;

return $this;
}
}
41 changes: 41 additions & 0 deletions src/Database/Migrations/Columns/Bit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace Phenix\Database\Migrations\Columns;

use InvalidArgumentException;

class Bit extends Column
{
public function __construct(
protected string $name,
protected int $limit = 1
) {
parent::__construct($name);
$this->options['limit'] = $limit;
}

public function getType(): string
{
return 'bit';
}

public function limit(int $limit): static
{
if ($limit < 1 || $limit > 64) {
throw new InvalidArgumentException('Bit limit must be between 1 and 64');
}

$this->options['limit'] = $limit;

return $this;
}

public function default(int $default): static
{
$this->options['default'] = $default;

return $this;
}
}
69 changes: 69 additions & 0 deletions src/Database/Migrations/Columns/Blob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);

namespace Phenix\Database\Migrations\Columns;

use Phinx\Db\Adapter\MysqlAdapter;

class Blob extends Column
{
public function __construct(
protected string $name,
protected int|null $limit = null
) {
parent::__construct($name);

if ($limit !== null) {
$this->options['limit'] = $limit;
}
}

public function getType(): string
{
return 'blob';
}

public function limit(int $limit): static
{
$this->options['limit'] = $limit;

return $this;
}

public function tiny(): static
{
if ($this->isMysql()) {
$this->options['limit'] = MysqlAdapter::BLOB_TINY;
}

return $this;
}

public function regular(): static
{
if ($this->isMysql()) {
$this->options['limit'] = MysqlAdapter::BLOB_REGULAR;
}

return $this;
}

public function medium(): static
{
if ($this->isMysql()) {
$this->options['limit'] = MysqlAdapter::BLOB_MEDIUM;
}

return $this;
}

public function long(): static
{
if ($this->isMysql()) {
$this->options['limit'] = MysqlAdapter::BLOB_LONG;
}

return $this;
}
}
20 changes: 20 additions & 0 deletions src/Database/Migrations/Columns/Boolean.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Phenix\Database\Migrations\Columns;

class Boolean extends Column
{
public function getType(): string
{
return 'boolean';
}

public function default(bool $value): static
{
$this->options['default'] = $value;

return $this;
}
}
53 changes: 53 additions & 0 deletions src/Database/Migrations/Columns/Char.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace Phenix\Database\Migrations\Columns;

class Char extends Column
{
public function __construct(
protected string $name,
protected int $limit = 255
) {
parent::__construct($name);
$this->options['limit'] = $limit;
}

public function getType(): string
{
return 'char';
}

public function limit(int $limit): static
{
$this->options['limit'] = $limit;

return $this;
}

public function collation(string $collation): static
{
if ($this->isMysql()) {
$this->options['collation'] = $collation;
}

return $this;
}

public function encoding(string $encoding): static
{
if ($this->isMysql()) {
$this->options['encoding'] = $encoding;
}

return $this;
}

public function default(string $default): static
{
$this->options['default'] = $default;

return $this;
}
}
20 changes: 20 additions & 0 deletions src/Database/Migrations/Columns/Cidr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Phenix\Database\Migrations\Columns;

class Cidr extends Column
{
public function getType(): string
{
return 'cidr';
}

public function default(string $default): static
{
$this->options['default'] = $default;

return $this;
}
}
Loading