PHPackages                             umbrellio/laravel-postgres-driver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. umbrellio/laravel-postgres-driver

Abandoned → laravel-pg-extensionsLibrary[Database &amp; ORM](/categories/database)

umbrellio/laravel-postgres-driver
=================================

Extensions for Postgres Laravel

7.2.0(11mo ago)1001819[2 issues](https://github.com/umbrellio/laravel-pg-extensions/issues)[3 PRs](https://github.com/umbrellio/laravel-pg-extensions/pulls)MITPHPPHP ^8.3|^8.4CI passing

Since Jun 9Pushed 8mo ago9 watchersCompare

[ Source](https://github.com/umbrellio/laravel-pg-extensions)[ Packagist](https://packagist.org/packages/umbrellio/laravel-postgres-driver)[ RSS](/packages/umbrellio-laravel-postgres-driver/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (7)Versions (79)Used By (0)

Laravel PG extensions
=====================

[](#laravel-pg-extensions)

[![Github Status](https://github.com/umbrellio/laravel-pg-extensions/workflows/CI/badge.svg)](https://github.com/umbrellio/laravel-pg-extensions/actions)[![Coverage Status](https://camo.githubusercontent.com/aa3afae50738b0c0e77a44b82d5b3190342460b6804ea4ce8ef557c2a2f2b77a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f756d6272656c6c696f2f6c61726176656c2d70672d657874656e73696f6e732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/umbrellio/laravel-pg-extensions?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/ea19aa9687d266969b8fce89c45b6cd7557f5ff2b5e165678e492c0e180cfbd3/68747470733a2f2f706f7365722e707567782e6f72672f756d6272656c6c696f2f6c61726176656c2d70672d657874656e73696f6e732f762f737461626c652e706e67)](https://packagist.org/packages/umbrellio/laravel-pg-extensions)[![Total Downloads](https://camo.githubusercontent.com/2f25aea3599314c71107534cb879b35e61d686adfc78cdd7e3c98ef7c8c535b6/68747470733a2f2f706f7365722e707567782e6f72672f756d6272656c6c696f2f6c61726176656c2d70672d657874656e73696f6e732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/umbrellio/laravel-pg-extensions)[![Code Intelligence Status](https://camo.githubusercontent.com/cd274a774467a2ec1f870dceb244b5799909c5542dd0b3fbc8d0ff1483d2c5e5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756d6272656c6c696f2f6c61726176656c2d70672d657874656e73696f6e732f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![Build Status](https://camo.githubusercontent.com/1aef57ca639e4d4d07ce5f3f2477fdae183cc7c6edf0a1ede0f11431192f3ef9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756d6272656c6c696f2f6c61726176656c2d70672d657874656e73696f6e732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/umbrellio/laravel-pg-extensions/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/1012c157e6b53578a971cfd78926a0dbf88db8f4beb4904b8a524fbe04586027/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756d6272656c6c696f2f6c61726176656c2d70672d657874656e73696f6e732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/umbrellio/laravel-pg-extensions/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/73d57620a7400e9b2bcdcadc2d7459e1a07ce4a5dfe706e3e428947ba5c72ac4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756d6272656c6c696f2f6c61726176656c2d70672d657874656e73696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/umbrellio/laravel-pg-extensions/?branch=master)

This project extends Laravel's database layer to allow use specific Postgres features without raw queries.

Installation
------------

[](#installation)

Run this command to install:

```
composer require umbrellio/laravel-pg-extensions
```

Features
--------

[](#features)

- [Extended `Schema::create()`](#extended-table-creation)
- [Added Support NUMERIC Type](#numeric-column-type)
- [Extended `Schema` with USING](#extended-schema-using)
- [Extended `Schema` for views](#create-views)
- [Working with UNIQUE indexes](#extended-unique-indexes-creation)
- [Working with EXCLUDE constraints](#exclude-constraints-creation)
- [Working with CHECK constraints](#check-constraints-creation)
- [Working with partitions](#partitions)
- [Check existing index before manipulation](#check-existing-index)
- [Getting foreign keys for table](#get-foreign-keys)

### Extended table creation

[](#extended-table-creation)

Example:

```
Schema::create('table', function (Blueprint $table) {
    $table->like('other_table')->includingAll();
    $table->ifNotExists();
});
```

### Extended Schema USING

[](#extended-schema-using)

Example:

```
Schema::create('table', function (Blueprint $table) {
    $table->integer('number');
});

//modifications with data...

Schema::table('table', function (Blueprint $table) {
    $table
        ->string('number')
        ->using("('[' || number || ']')::character varying")
        ->change();
});
```

### Create views

[](#create-views)

Example:

```
// Facade methods:
Schema::createView('active_users', "SELECT * FROM users WHERE active = 1");
Schema::dropView('active_users')

// Schema methods:
Schema::create('users', function (Blueprint $table) {
    $table
        ->createView('active_users', "SELECT * FROM users WHERE active = 1")
        ->materialize();
});
```

### Get foreign keys

[](#get-foreign-keys)

Example:

```
// Facade methods:
/** @var ForeignKeyDefinition[] $fks */
$fks = Schema::getForeignKeys('some_table');

foreach ($fks as $fk) {
    // $fk->source_column_name
    // $fk->target_table_name
    // $fk->target_column_name
}
```

### Extended unique indexes creation

[](#extended-unique-indexes-creation)

Example:

```
Schema::create('table', function (Blueprint $table) {
    $table->string('code');
    $table->softDeletes();
    $table->uniquePartial('code')->whereNull('deleted_at');
});
```

If you want to delete partial unique index, use this method:

```
Schema::create('table', function (Blueprint $table) {
    $table->dropUniquePartial(['code']);
});
```

`$table->dropUnique()` doesn't work for Partial Unique Indexes, because PostgreSQL doesn't define a partial (ie conditional) UNIQUE constraint. If you try to delete such a Partial Unique Index you will get an error.

```
CREATE UNIQUE INDEX CONCURRENTLY examples_new_col_idx ON examples (new_col);
ALTER TABLE examples
    ADD CONSTRAINT examples_unique_constraint USING INDEX examples_new_col_idx;
```

When you create a unique index without conditions, PostgresSQL will create Unique Constraint automatically for you, and when you try to delete such an index, Constraint will be deleted first, then Unique Index.

### Exclude constraints creation

[](#exclude-constraints-creation)

Using the example below:

```
Schema::create('table', function (Blueprint $table) {
    $table->integer('type_id');
    $table->date('date_start');
    $table->date('date_end');
    $table->softDeletes();
    $table
        ->exclude(['date_start', 'date_end'])
        ->using('type_id', '=')
        ->using('daterange(date_start, date_end)', '&&')
        ->method('gist')
        ->with('some_arg', 1)
        ->with('any_arg', 'some_value')
        ->whereNull('deleted_at');
});
```

An Exclude Constraint will be generated for your table:

```
ALTER TABLE test_table
    ADD CONSTRAINT test_table_date_start_date_end_excl
        EXCLUDE USING gist (type_id WITH =, daterange(date_start, date_end) WITH &&)
        WITH (some_arg = 1, any_arg = 'some_value')
        WHERE ("deleted_at" is null)
```

### Check constraints creation

[](#check-constraints-creation)

Using the example below:

```
Schema::create('table', function (Blueprint $table) {
    $table->integer('type_id');
    $table->date('date_start');
    $table->date('date_end');
    $table
        ->check(['date_start', 'date_end'])
        ->whereColumn('date_end', '>', 'date_start')
        ->whereIn('type_id', [1, 2, 3]);
});
```

An Check Constraint will be generated for your table:

```
ALTER TABLE test_table
    ADD CONSTRAINT test_table_date_start_date_end_chk
        CHECK ("date_end" > "date_start" AND "type_id" IN [1, 2, 3])
```

### Partitions

[](#partitions)

Support for attaching and detaching partitions.

Example:

```
Schema::table('table', function (Blueprint $table) {
    $table->attachPartition('partition')->range([
        'from' => now()->startOfDay(), // Carbon will be converted to date time string
        'to' => now()->tomorrow(),
    ]);
});
```

### Check existing index

[](#check-existing-index)

```
Schema::table('some_table', function (Blueprint $table) {
   // check unique index exists on column
   if ($table->hasIndex(['column'], true)) {
      $table->dropUnique(['column']);
   }
   $table->uniquePartial('column')->whereNull('deleted_at');
});
```

### Numeric column type

[](#numeric-column-type)

Unlike standard laravel `decimal` type, this type can be with [variable precision](https://www.postgresql.org/docs/current/datatype-numeric.html)

```
Schema::table('some_table', function (Blueprint $table) {
   $table->numeric('column_with_variable_precision');
   $table->numeric('column_with_defined_precision', 8);
   $table->numeric('column_with_defined_precision_and_scale', 8, 2);
});
```

Custom Extensions
-----------------

[](#custom-extensions)

1). Create a repository for your extension.

2). Add this package as a dependency in composer.

3). Inherit the classes you intend to extend from abstract classes with namespace: `namespace Umbrellio\Postgres\Extensions`

4). Implement extension methods in closures, example:

```
use Umbrellio\Postgres\Extensions\Schema\AbstractBlueprint;
class SomeBlueprint extends AbstractBlueprint
{
   public function someMethod()
   {
       return function (string $column): Fluent {
           return $this->addColumn('someColumn', $column);
       };
   }
}
```

5). Create Extension class and mix these methods using the following syntax, ex:

```
use Umbrellio\Postgres\PostgresConnection;
use Umbrellio\Postgres\Schema\Blueprint;
use Umbrellio\Postgres\Schema\Grammars\PostgresGrammar;
use Umbrellio\Postgres\Extensions\AbstractExtension;

class SomeExtension extends AbstractExtension
{
    public static function getMixins(): array
    {
        return [
            SomeBlueprint::class => Blueprint::class,
            SomeConnection::class => PostgresConnection::class,
            SomeSchemaGrammar::class => PostgresGrammar::class,
            ...
        ];
    }

    public static function getTypes(): string
    {
        // where SomeType extends Doctrine\DBAL\Types\Type
        return [
            'some' => SomeType::class,
        ];
    }

    public static function getName(): string
    {
        return 'some';
    }
}
```

6). Register your Extension in ServiceProvider and put in config/app.php, ex:

```
use Illuminate\Support\ServiceProvider;
use Umbrellio\Postgres\PostgresConnection;

class SomeServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        PostgresConnection::registerExtension(SomeExtension::class);
    }
}
```

TODO features
-------------

[](#todo-features)

- Extend `CreateCommand` with `inherits` and `partition by`
- Extend working with partitions
- COPY support
- DISTINCT on specific columns
- INSERT ON CONFLICT support
- ...

License
-------

[](#license)

Released under MIT License.

Authors
-------

[](#authors)

Created by Vitaliy Lazeev &amp; Korben Dallas.

Contributing
------------

[](#contributing)

- Fork it (  )
- Create your feature branch (`git checkout -b feature/my-new-feature`)
- Commit your changes (`git commit -am 'Add some feature'`)
- Push to the branch (`git push origin feature/my-new-feature`)
- Create new Pull Request

[![Supported by Umbrellio](https://camo.githubusercontent.com/cfae343fcdcb3e8680353f5f058271ed6a749151ae073ae4d9e083e5e1aeb045/68747470733a2f2f756d6272656c6c696f2e6769746875622e696f2f556d6272656c6c696f2f737570706f727465645f62795f756d6272656c6c696f2e737667)](https://github.com/umbrellio/)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance56

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community26

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 61.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~23 days

Total

70

Last Release

248d ago

Major Versions

2.7.0 → 3.0.02019-09-10

3.0.0 → 4.0.02019-10-18

4.5.3 → 5.0.02020-12-24

5.3.10 → 6.0.02024-04-24

6.0.2 → 7.0.02024-05-02

PHP version history (6 changes)1.0.0PHP ^7.2

4.4.0PHP 7.\*

4.5.0PHP ^7.2|^7.3|^7.4

4.5.1PHP ^7.2|^7.3|^7.4|^8.0

6.0.0PHP ^7.2|^7.3|^7.4|^8.0|^8.1|^8.2

7.0.0PHP ^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc9857312ea8b712392a916097419ba7eff3c0588efb3115ff1ddfd468e57ac5?d=identicon)[lazeevv\_](/maintainers/lazeevv_)

![](https://www.gravatar.com/avatar/c06a2f350de2f765fa82fe6a9a50fda78b9cfa380c849f1fa184fd21917093ef?d=identicon)[0exp](/maintainers/0exp)

---

Top Contributors

[![pvsaintpe](https://avatars.githubusercontent.com/u/16900171?v=4)](https://github.com/pvsaintpe "pvsaintpe (60 commits)")[![lazeevv](https://avatars.githubusercontent.com/u/36244644?v=4)](https://github.com/lazeevv "lazeevv (20 commits)")[![fuwasegu](https://avatars.githubusercontent.com/u/52437973?v=4)](https://github.com/fuwasegu "fuwasegu (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![danieljaniga](https://avatars.githubusercontent.com/u/3395781?v=4)](https://github.com/danieljaniga "danieljaniga (2 commits)")[![Zlob](https://avatars.githubusercontent.com/u/3818931?v=4)](https://github.com/Zlob "Zlob (2 commits)")[![kvatra](https://avatars.githubusercontent.com/u/23643570?v=4)](https://github.com/kvatra "kvatra (1 commits)")[![mpyw](https://avatars.githubusercontent.com/u/1351893?v=4)](https://github.com/mpyw "mpyw (1 commits)")[![qem19](https://avatars.githubusercontent.com/u/49522198?v=4)](https://github.com/qem19 "qem19 (1 commits)")[![siketyan](https://avatars.githubusercontent.com/u/12772118?v=4)](https://github.com/siketyan "siketyan (1 commits)")[![Kriso1337](https://avatars.githubusercontent.com/u/26929000?v=4)](https://github.com/Kriso1337 "Kriso1337 (1 commits)")[![flemeur](https://avatars.githubusercontent.com/u/898359?v=4)](https://github.com/flemeur "flemeur (1 commits)")[![gitHomesPhp](https://avatars.githubusercontent.com/u/57961085?v=4)](https://github.com/gitHomesPhp "gitHomesPhp (1 commits)")[![KentarouTakeda](https://avatars.githubusercontent.com/u/4785040?v=4)](https://github.com/KentarouTakeda "KentarouTakeda (1 commits)")[![Kosadchiy](https://avatars.githubusercontent.com/u/35429123?v=4)](https://github.com/Kosadchiy "Kosadchiy (1 commits)")[![cugrif](https://avatars.githubusercontent.com/u/52412060?v=4)](https://github.com/cugrif "cugrif (1 commits)")

---

Tags

databaseextensionslaravelpostgresqlphplaravelschemapostgresqlpostgresbuildermigrationsextension

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/umbrellio-laravel-postgres-driver/health.svg)

```
[![Health](https://phpackages.com/badges/umbrellio-laravel-postgres-driver/health.svg)](https://phpackages.com/packages/umbrellio-laravel-postgres-driver)
```

###  Alternatives

[umbrellio/laravel-pg-extensions

Extensions for Postgres Laravel

102426.5k1](/packages/umbrellio-laravel-pg-extensions)[tpetry/laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features

9982.0M14](/packages/tpetry-laravel-postgresql-enhanced)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[umbrellio/laravel-ltree

Extension LTree (Postgres) for Laravel

34111.6k](/packages/umbrellio-laravel-ltree)[asmiarowski/laravel-postgres

Eloquent support for postgreSQL fields

1638.1k1](/packages/asmiarowski-laravel-postgres)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
