Skip to content

Commit

Permalink
add tsrange
Browse files Browse the repository at this point in the history
  • Loading branch information
pvsaintpe committed Dec 8, 2020
1 parent 8fd1bd0 commit 2512b61
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @method ViewDefinition createView(string $view, string $select, bool $materialize = false)
* @method Fluent dropView(string $view)
* @method ColumnDefinition numeric(string $column, ?int $precision = null, ?int $scale = null)
* @method ColumnDefinition tsrange(string $column)
* @method ExcludeDefinition exclude($columns, ?string $index = null)
* @method CheckDefinition check($columns, ?string $index = null)
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ public function numeric(string $column, ?int $precision = null, ?int $scale = nu
return $this->addColumn('numeric', $column, compact('precision', 'scale'));
}

public function tsrange(string $column): ColumnDefinition
{
return $this->addColumn('tsrange', $column);
}

protected function getSchemaManager()
{
return Schema::getConnection()->getDoctrineSchemaManager();
Expand Down
5 changes: 5 additions & 0 deletions src/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ protected function typeNumeric(Fluent $column): string

return $type;
}

protected function typeTsrange(Fluent $column): string
{
return 'tsrange';
}
}
9 changes: 9 additions & 0 deletions tests/Unit/Schema/Blueprint/PartitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public function attachPartitionRangeDates(): void
));
}

/**
* @test
*/
public function addingTsrangeColumn()
{
$this->blueprint->tsrange('foo');
$this->assertSameSql('alter table "test_table" add column "foo" tsrange not null');
}

/**
* @test
*/
Expand Down

0 comments on commit 2512b61

Please sign in to comment.