Skip to content

Commit

Permalink
finish up PK limit feature
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Peveler <[email protected]>
  • Loading branch information
MasterOdin committed Feb 23, 2021
1 parent 1df9486 commit 3f33a53
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/Phinx/Db/Adapter/PostgresAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ public function createTable(Table $table, array $columns = [], array $indexes =
->setType('integer')
->setIdentity(true);

if (isset($options['limit'])) {
$column->setLimit($options['limit']);
}

array_unshift($columns, $column);
if (isset($options['primary_key']) && (array)$options['id'] !== (array)$options['primary_key']) {
throw new InvalidArgumentException('You cannot enable an auto incrementing ID field and a primary key');
Expand Down
4 changes: 0 additions & 4 deletions src/Phinx/Db/Adapter/SQLiteAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,6 @@ public function createTable(Table $table, array $columns = [], array $indexes =
->setType('integer')
->setIdentity(true);

if (isset($options['limit'])) {
$column->setLimit($options['limit']);
}

array_unshift($columns, $column);
}

Expand Down
4 changes: 0 additions & 4 deletions src/Phinx/Db/Adapter/SqlServerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ public function createTable(Table $table, array $columns = [], array $indexes =
->setType('integer')
->setIdentity(true);

if (isset($options['limit'])) {
$column->setLimit($options['limit']);
}

array_unshift($columns, $column);
if (isset($options['primary_key']) && (array)$options['id'] !== (array)$options['primary_key']) {
throw new InvalidArgumentException('You cannot enable an auto incrementing ID field and a primary key');
Expand Down
10 changes: 10 additions & 0 deletions tests/Phinx/Db/Adapter/MysqlAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,16 @@ public function testCreateTableWithUnsignedNamedPK()
$this->assertFalse($this->adapter->hasColumn('ntable', 'address'));
}

public function testCreateTableWithLimitPK()
{
$table = new \Phinx\Db\Table('ntable', ['id' => 'id', 'limit' => 4], $this->adapter);
$table->save();
$this->assertTrue($this->adapter->hasTable('ntable'));
$this->assertTrue($this->adapter->hasColumn('ntable', 'id'));
$column_definitions = $this->adapter->getColumns('ntable');
$this->assertSame($this->usingMysql8() ? null : 4, $column_definitions[0]->getLimit());
}

public function testCreateTableWithSchema()
{
$table = new \Phinx\Db\Table(MYSQL_DB_CONFIG['name'] . '.ntable', [], $this->adapter);
Expand Down

0 comments on commit 3f33a53

Please sign in to comment.