Skip to content

Commit

Permalink
Merge pull request #20 from dsavina/feature/optional-index-name
Browse files Browse the repository at this point in the history
Add optional argument $indexName to index creation
  • Loading branch information
moufmouf authored Jan 6, 2021
2 parents 3a4e7e5 + a5e2a26 commit 64d63f6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"require": {
"php": ">=7.1",
"thecodingmachine/dbal-fluid-schema-builder": "^1.4",
"thecodingmachine/dbal-fluid-schema-builder": "^1.6",
"doctrine/dbal": "^2.5"
},
"require-dev": {
Expand Down
8 changes: 4 additions & 4 deletions src/TdbmFluidColumnOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function null(): self
*
* @return self
*/
public function unique(): self
public function unique(?string $indexName = null): self
{
$this->fluidColumnOptions->unique();
$this->fluidColumnOptions->unique($indexName);
return $this;
}

Expand All @@ -62,9 +62,9 @@ public function unique(): self
*
* @return self
*/
public function index(): self
public function index(?string $indexName = null): self
{
$this->fluidColumnOptions->index();
$this->fluidColumnOptions->index($indexName);
return $this;
}
public function comment(string $comment): self
Expand Down
8 changes: 4 additions & 4 deletions src/TdbmFluidTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ public function column(string $name): TdbmFluidColumn
return $this->tdbmFluidColumns[$name];
}

public function index(array $columnNames): TdbmFluidTable
public function index(array $columnNames, ?string $indexName = null): TdbmFluidTable
{
$this->fluidTable->index($columnNames);
$this->fluidTable->index($columnNames, $indexName);
return $this;
}

public function unique(array $columnNames): TdbmFluidTable
public function unique(array $columnNames, ?string $indexName = null): TdbmFluidTable
{
$this->fluidTable->unique($columnNames);
$this->fluidTable->unique($columnNames, $indexName);
return $this;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/TdbmFluidColumnOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function testOptions()
$columnOptions->notNull();
$this->assertSame(true, $dbalColumn->getNotnull());

$columnOptions->unique();
$this->assertSame(true, $dbalColumn->getCustomSchemaOption('unique'));
$columnOptions->unique('unique_foo');
$this->assertSame(true, $posts->getDbalTable()->getIndex('unique_foo')->isUnique());

$columnOptions->comment('foo');
$this->assertSame('foo', $dbalColumn->getComment());
Expand Down

0 comments on commit 64d63f6

Please sign in to comment.