diff --git a/src/Bosnadev/Database/Schema/Blueprint.php b/src/Bosnadev/Database/Schema/Blueprint.php index 8580091..089f9f9 100644 --- a/src/Bosnadev/Database/Schema/Blueprint.php +++ b/src/Bosnadev/Database/Schema/Blueprint.php @@ -260,4 +260,16 @@ public function tsvector($column) { return $this->addColumn('tsvector', $column); } + + /** + * Create a new citext column on the table. + * + * @param $column + * + * @return \Illuminate\Support\Fluent + */ + public function citext($column) + { + return $this->addColumn('citext', $column); + } } diff --git a/src/Bosnadev/Database/Schema/Grammars/PostgresGrammar.php b/src/Bosnadev/Database/Schema/Grammars/PostgresGrammar.php index fb13fcc..ae8ab8d 100644 --- a/src/Bosnadev/Database/Schema/Grammars/PostgresGrammar.php +++ b/src/Bosnadev/Database/Schema/Grammars/PostgresGrammar.php @@ -278,6 +278,18 @@ protected function typeTsvector(Fluent $column) return "tsvector"; } + /** + * Create the column definition for a Case Insensitive Text type. + * + * @param Fluent $column + * + * @return string + */ + protected function typeCitext(Fluent $column) + { + return "citext"; + } + /** * @param mixed $value * @return mixed|string diff --git a/tests/Schema/BlueprintTest.php b/tests/Schema/BlueprintTest.php index 759d05e..16be8d7 100644 --- a/tests/Schema/BlueprintTest.php +++ b/tests/Schema/BlueprintTest.php @@ -112,4 +112,13 @@ public function testTstzrange() $this->blueprint->tstzrange('col'); } + + public function testCitext() + { + $this->blueprint + ->shouldReceive('addColumn') + ->with('citext', 'col'); + + $this->blueprint->citext('col'); + } } diff --git a/tests/Schema/Grammars/PostgresGrammarTest.php b/tests/Schema/Grammars/PostgresGrammarTest.php index cf7e688..028d602 100644 --- a/tests/Schema/Grammars/PostgresGrammarTest.php +++ b/tests/Schema/Grammars/PostgresGrammarTest.php @@ -170,6 +170,20 @@ public function testAddingTsvector() $this->assertContains('add column "foo" tsvector', $statements[0]); } + public function testAddingCitext() + { + $blueprint = new Blueprint('test'); + $blueprint->citext('foo'); + $statements = $blueprint->toSql( + $this->getConnection(), + $this->getGrammar() + ); + + $this->assertEquals(1, count($statements)); + $this->assertContains('alter table', $statements[0]); + $this->assertContains('add column "foo" citext', $statements[0]); + } + /** * @return PostgresConnection */