Search by

efureev / laravel-support-db

efureev

PostgreSQL features for Laravel's schema and query builders: partial indexes, views, CREATE TABLE LIKE, extensions, RETURNING, and PostgreSQL-only column types

Package info

github.com/efureev/laravel-support-db

pkg:composer/efureev/laravel-support-db

Statistics

Installs: 7 168

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 0

v5.5.0 2026-09-12 23:34 UTC

README

PHP >= 8.5 Laravel >= 13.0 CI Codacy Badge Latest Stable Version Total Downloads

PostgreSQL features for Laravel's schema and query builders.

Laravel's builders cover what every database can do. This package adds the PostgreSQL parts they leave out — partial indexes, views, CREATE TABLE … LIKE, extensions, RETURNING, and the PostgreSQL-only column types — using the same fluent style, so they read like the rest of a migration.

It extends; it does not replace. Everything the framework already does keeps working unchanged.

Schema::create('users', static function (Blueprint $table) {
    $table->primaryUUID();
    $table->string('email');
    $table->softDeletes();

    // one live user per address; soft-deleted rows do not collide
    $table->uniquePartial('email')->whereNull('deleted_at');
});

Install

composer require efureev/laravel-support-db

It registers itself through package discovery — no provider to add, no config to publish. Type-hint the package's Blueprint in migrations to get the additions in your editor:

use Illuminate\Support\Facades\Schema;
use Php\Support\Laravel\Database\Schema\Postgres\Blueprint;

Schema::create('table', static function (Blueprint $table) { /* … */ });
Version
PHP >= 8.5
Laravel >= 13.0 (illuminate/database)
PostgreSQL 13 – 18, every one of them exercised in CI

compression() needs PostgreSQL 14 and nullsNotDistinct() needs 15; everything else works from 13. The package takes effect on pgsql connections only — other drivers on the same application are untouched.

Documentation

Read it at https://efureev.github.io/laravel-support-db/, or as markdown in docs/.

The docs/ directory is not shipped in the Composer package — it would be dead weight in vendor/ — which is why the links below are absolute.

Page Covers
Getting started Requirements, version floors, how the package hooks in, a first migration
Columns The PostgreSQL-only column types, UUID key generation, TOAST compression
Indexes Partial and unique-partial indexes, predicates, modifiers, GIN operator classes
Views Plain and materialized views — create, refresh, inspect, drop, other schemas
Schema operations CREATE TABLE … LIKE / AS TABLE / AS SELECT, DROP … CASCADE, extensions
Query builder RETURNING on UPDATE and DELETE
Recipes Thirteen realistic problems worked end to end
Behaviour notes The things that are easy to trip over, and what Laravel 13 already does itself
Testing & contributing Running the suite, and the gate a pull request has to pass

What it adds

Partial and unique-partial indexes with a fluent WHERE · CREATE INDEX CONCURRENTLY and NULLS NOT DISTINCT on them · GIN indexes with an operator class · views, including materialized ones, with schema-qualified lookups · CREATE TABLE … LIKE / AS SELECT / AS TABLE · DROP TABLE … CASCADE · CREATE / DROP EXTENSION · column compression · UPDATE / DELETE … RETURNING · and shorthands for bit, numeric, xml, cidr, daterange, tsrange, the geometric types, the array types, and UUID primary keys that need no extension.

Contributing

Issues and pull requests are welcome — see Testing & contributing for the gate CI runs.

License

MIT — see LICENSE.