Download the PHP package kosovojs/laravel-pg-identity without Composer
On this page you can find all versions of the php package kosovojs/laravel-pg-identity. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kosovojs/laravel-pg-identity
More information about kosovojs/laravel-pg-identity
Files in kosovojs/laravel-pg-identity
Package laravel-pg-identity
Short Description PostgreSQL identity columns for Laravel's id() and increments() — replaces legacy serial, zero config
License MIT
Informations about the package laravel-pg-identity
laravel-pg-identity
PostgreSQL identity columns for Laravel's id() and increments() — replaces legacy serial, zero config.
What it does
On PostgreSQL, Laravel's $table->id() and increments() family generate legacy bigserial/serial columns. This package makes them generate modern identity columns instead, with no configuration required.
Install
That's it — Laravel's package auto-discovery does the rest.
How it works
The package registers a pgsql connection resolver that swaps in a PostgresConnection subclass. That subclass uses a PostgresGrammar subclass which, for auto-increment integer columns, sets generatedAs/always before delegating back to the parent grammar. Laravel's own existing modifiers then render the generated always as identity ... primary key clause and skip the serial types on their own.
Testing
Unit tests (no DB required):
End-to-end tests (installs the package into a throwaway Laravel app and checks the generated schema against real sqlite/MariaDB/Postgres databases):
Caveats
GENERATED ALWAYSrejects explicit id inserts unless the query usesOVERRIDING SYSTEM VALUE. If you seed rows with fixed ids, the simplest opt-out is$table->id()->always(false), which givesGENERATED BY DEFAULTbehavior while keeping everything else (identity type, primary key, etc). You can also call->generatedAs()yourself on that column — the package never touches columns wheregeneratedAsis already set — for the same effect.- Only affects new migrations/columns — existing
serialcolumns in your database aren't rewritten. - Requires Laravel 12–13.
- If another package also calls
Connection::resolverFor('pgsql', ...), last one registered wins.
All versions of laravel-pg-identity with dependencies
illuminate/database Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0