Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Postgresql Enhanced

Laravel Postgresql Enhanced Laravel Package

tpetry/laravel-postgresql-enhanced

Adds PostgreSQL-specific power to Laravel beyond the “lowest common denominator”: enhanced migrations (zero-downtime, extensions, functions, triggers, views/materialized views), advanced indexes (concurrent, partial, include, full-text, temporal), domains and table options.

View on GitHub
Deep Wiki
Context7

Support for many missing PostgreSQL specific features

Frequently asked questions about Laravel Postgresql Enhanced
How do I enable zero-downtime migrations in Laravel with this package?
Use the `zeroDowntime()` method in your migration blueprint. The package handles the PostgreSQL-specific syntax for creating temporary tables and swapping them atomically. Example: `$table->zeroDowntime()->string('column');`. Always test in staging first, as this requires careful transaction management.
Can I use this package with Laravel 10+? What’s the compatibility?
Check the package’s [Laravel compatibility table](https://github.com/tpetry/laravel-postgresql-enhanced#laravel-compatibility) for exact versions. Major versions align with Laravel’s releases, so upgrading Laravel may require a matching package update. Minor/patch updates are safe per semantic versioning. Always review breaking changes before upgrading.
Does this package support PostgreSQL extensions like TimescaleDB or pg_trgm?
Yes, the package includes methods for creating and managing PostgreSQL extensions directly in migrations. Use `$table->extension('timescaledb')` or `$table->extension('pg_trgm')`. Ensure your PostgreSQL server has the extension installed and your user has permissions to create it.
How do I create a materialized view in Laravel using this package?
Use the `materializedView()` method in your migration: `$table->materializedView('view_name', function($table) { ... });`. The package generates the `CREATE MATERIALIZED VIEW` SQL with your defined columns and indexes. Refresh it manually with `REFRESH MATERIALIZED VIEW` or via Laravel queries.
Will this package work with my existing Laravel app without breaking changes?
The package is designed for incremental adoption. Start by replacing raw SQL workarounds (e.g., `RETURNING` clauses, `ON CONFLICT`) with the package’s methods. Use feature flags to toggle between old and new syntax during migration. Always test in a staging environment with a PostgreSQL replica.
How do I handle functional indexes (e.g., indexing JSONB paths) in Laravel?
Use the `functionalIndex()` method: `$table->functionalIndex('jsonb_column->>key', 'idx_name');`. The package supports PostgreSQL’s `expression` indexes, including JSONB paths, array operations, and custom functions. Combine with `includeColumns()` for covering indexes.
What’s the best way to test PostgreSQL-specific features like triggers in CI?
Use Laravel’s `Schema::getConnection()->getPdo()` to run raw SQL tests for complex features. Mock the database in unit tests, but test triggers/functions in integration tests with a real PostgreSQL instance. Tools like `pest` or `phpunit` with `DatabaseTransactions` can help isolate tests.
Are there performance implications for using this package’s advanced indexes?
Functional, partial, or full-text indexes may improve query performance but add write overhead. Benchmark with `EXPLAIN ANALYZE` in PostgreSQL. Avoid over-indexing; use `includeColumns()` for covering indexes to reduce I/O. Monitor autovacuum stats for high-write tables.
How do I roll back a failed zero-downtime migration?
Zero-downtime migrations use temporary tables, so rollback typically involves dropping the temporary table and reverting to the original schema. The package doesn’t auto-rollback; manually handle errors by wrapping migrations in transactions and using `DB::transaction()` with custom rollback logic.
What alternatives exist for PostgreSQL-specific Laravel features?
For basic PostgreSQL support, Laravel’s native `DB` facade works, but lacks advanced features. Alternatives like `spatie/laravel-postgres-array` focus on JSONB arrays, while raw SQL queries offer full control but no IDE support. This package bridges the gap by providing Laravel-native syntax for PostgreSQL’s unique capabilities.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
bugban/symfony
beyonder-capi/workflow-extensions-bundle
beyonder-capi/job-queue-bundle
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin