PHPackages                             dibiy/onpgschemas - 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. dibiy/onpgschemas

ActiveLibrary[Database &amp; ORM](/categories/database)

dibiy/onpgschemas
=================

Laravel package for managing postgresql schemas

098PHP

Since May 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/dibiY/onpgschemas)[ Packagist](https://packagist.org/packages/dibiy/onpgschemas)[ RSS](/packages/dibiy-onpgschemas/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel PGSchema
================

[](#laravel-pgschema)

With this package you can create, switch and drop postgresql schemas easily. This is very useful when you are working with multi-tenants applications.

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

[](#installation)

1. Use composer to add the package into your project using `composer require dibiy/onpgschemas:dev-master`
2. Add 'Onpgschemas\\SchemasServiceProvider' to your app.php file in the services providers section.
3. Add 'Onpgschemas' =&gt; 'Onpgschemas\\Facades\\Onpgschemas' into the aliases section

Usage
-----

[](#usage)

Assuming that you have your db configuration ready, meaning that your default connection is 'pgsql' and your pgsql credentials are setted in the usual way, you can use the next functions:

### Create new Schema

[](#create-new-schema)

`Onpgschemas::create($schemaName)`

### Switch to Schema

[](#switch-to-schema)

`Onpgschemas::switchTo($schemaName)`

if switchTo is call without arguments, it switches to the public schema (default)

### Drop Schema

[](#drop-schema)

`Onpgschemas::drop($schemaName)`

### Migrate Schema

[](#migrate-schema)

`Onpgschemas::migrate($schemaName, args[])`

For example create a migrations in a custom path: `php artisan migrate:make create_dogs_table --create=dogs --path=database/migrations/foo`

Then you can migrate some schema using this path `PGSchema::migrate($schemaName, ['--path' => 'database/migrations/foo'])`

Multi-tenancy Example (SaaS)
----------------------------

[](#multi-tenancy-example-saas)

Checkout this repo In the handlers folder you can find the code that contains calls to the package.

Laravel version
---------------

[](#laravel-version)

Current package version works for Laravel 5/6/7/8.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9032780afbb77de26b21d8c9a1fc2a5df15d932ba271a9c89f5cadc8e9a2cf7a?d=identicon)[dibiY](/maintainers/dibiY)

---

Top Contributors

[![YassineDi](https://avatars.githubusercontent.com/u/77504366?v=4)](https://github.com/YassineDi "YassineDi (13 commits)")

### Embed Badge

![Health badge](/badges/dibiy-onpgschemas/health.svg)

```
[![Health](https://phpackages.com/badges/dibiy-onpgschemas/health.svg)](https://phpackages.com/packages/dibiy-onpgschemas)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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