Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions src/Bosnadev/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
12 changes: 12 additions & 0 deletions src/Bosnadev/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
14 changes: 14 additions & 0 deletions tests/Schema/Grammars/PostgresGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down