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 5y ago1 watchersCompare

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

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

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity30

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://avatars.githubusercontent.com/u/46802078?v=4)[dibiY](/maintainers/dibiY)[@dibiY](https://github.com/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

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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