PHPackages                             racklin/pgschema - 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. racklin/pgschema

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

racklin/pgschema
================

postgresql schemas for laravel 5

5.x-dev(5y ago)225.9k12[2 issues](https://github.com/racklin/pgschema/issues)[1 PRs](https://github.com/racklin/pgschema/pulls)MITPHPPHP &gt;=7.0.0

Since Nov 4Pushed 2y ago2 watchersCompare

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

READMEChangelogDependencies (3)Versions (2)Used By (0)

PostgreSQL Schema manager for Laravel
=====================================

[](#postgresql-schema-manager-for-laravel)

This is very useful when you are working with multi-tenants applications with PostgreSQL Schemas.

With facade helper functions, you can create/drop/switch schemas easily. This package also provide artisan commands for migrations and seeds supports for each schemas.

PGSchema will check and only affects when specific connection driver is `pgsql`. So you can using PGSchema to your projects safely with any database connection drivers without error occurred.

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

[](#laravel-version)

Current package version works for Laravel `5+` .

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

[](#installation)

1. Use composer to add the package into your project

```
composer require racklin/pgschema:dev-master

```

2. Add service provider into your providers array in `config/app.php`

```
Racklin\PGSchema\PGSchemaServiceProvider::class,

```

3. Add alias to aliases array in `config/app.php`

```
'PGSchema' => Racklin\PGSchema\Facades\PGSchema::class,

```

Artisan Commands
----------------

[](#artisan-commands)

### pgschema:migrate

[](#pgschemamigrate)

`pgschema:migrate` add extra `schema` option to Laravel `migrate` command, you can specific the database schema for migrations. And it will auto install `migrations` repository table for the schema.

```
Usage:
  pgschema:migrate [options]

Options:
      --database[=DATABASE]  The database connection to use.
      --schema[=SCHEMA]      The database schema to use.
      --force                Force the operation to run when in production.
      --path[=PATH]          The path of migrations files to be executed.
      --pretend              Dump the SQL queries that would be run.
      --seed                 Indicates if the seed task should be re-run.
      --step                 Force the migrations to be run so they can be rolled back individually.
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
      --env[=ENV]            The environment the command should run under
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Run the database migrations

```

### pgschema:rollback

[](#pgschemarollback)

`pgschema:rollback` add extra `schema` option to Laravel `migrate:rollback` command.

```
Usage:
  pgschema:rollback [options]

Options:
      --database[=DATABASE]  The database connection to use.
      --force                Force the operation to run when in production.
      --path[=PATH]          The path of migrations files to be executed.
      --pretend              Dump the SQL queries that would be run.
      --step[=STEP]          The number of migrations to be reverted.
      --schema[=SCHEMA]      The database schema to use
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
      --env[=ENV]            The environment the command should run under
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Rollback the last database migration

```

### pgschema:reset

[](#pgschemareset)

`pgschema:reset` add extra `schema` option to Laravel `migrate:reset` command.

```
Usage:
  pgschema:reset [options]

Options:
      --database[=DATABASE]  The database connection to use.
      --force                Force the operation to run when in production.
      --path[=PATH]          The path of migrations files to be executed.
      --pretend              Dump the SQL queries that would be run.
      --schema[=SCHEMA]      The database schema to use
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
      --env[=ENV]            The environment the command should run under
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Rollback all database migrations

```

### pgschema:refresh

[](#pgschemarefresh)

`pgschema:refresh` add extra `schema` option to Laravel `migrate:refresh` command.

```
Usage:
  pgschema:refresh [options]

Options:
      --database[=DATABASE]  The database connection to use.
      --force                Force the operation to run when in production.
      --path[=PATH]          The path of migrations files to be executed.
      --seed                 Indicates if the seed task should be re-run.
      --seeder[=SEEDER]      The class name of the root seeder.
      --step[=STEP]          The number of migrations to be reverted & re-run.
      --schema[=SCHEMA]      The database schema to use
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
      --env[=ENV]            The environment the command should run under
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Reset and re-run all migrations

```

### pgschema:seed

[](#pgschemaseed)

`pgschema:seed` add extra `schema` option to Laravel `db:seed` command.

```
Usage:
  pgschema:seed [options]

Options:
      --class[=CLASS]        The class name of the root seeder [default: "DatabaseSeeder"]
      --database[=DATABASE]  The database connection to seed
      --schema[=SCHEMA]      The database schema to seed
      --force                Force the operation to run when in production.
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
      --env[=ENV]            The environment the command should run under
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Seed the database with records

```

### pgschema:create-schema

[](#pgschemacreate-schema)

`pgschema:create-schema` create `schema` for `database` .

```
Usage:
  pgschema:create-schema [options] [--]

Arguments:
  schema                     The database schema to create

Options:
      --database[=DATABASE]  The database connection to use
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
      --env[=ENV]            The environment the command should run under
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

```

Facade Helper Functions
-----------------------

[](#facade-helper-functions)

### Create new Schema

[](#create-new-schema)

`PGSchema::create($schemaName, $databaseName)`

if create is call without $databaseName argument, it using the default connection.

### Drop Schema

[](#drop-schema)

`PGSchema::drop($schemaName, $databaseName)`

if drop is call without $databaseName argument, it using the default connection.

### Switch Schema

[](#switch-schema)

`PGSchema::schema($schemaName, $databaseName)`

if schema is call without $schemaName argument, it switches to the public schema (default) if schema is call without $databaseName argument, it using the default connection.

### Iterating Schemas

[](#iterating-schemas)

`PGSchema::each(Closure $callback, $databaseName)`

if each is call without $databaseName argument, it using the default connection.

License
-------

[](#license)

MIT:

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

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

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2022d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/98798029ea572caf2d23d4fe81ad2a82ffdbfa86393e267f6bedaf2cc705f2d9?d=identicon)[racklin](/maintainers/racklin)

---

Top Contributors

[![racklin](https://avatars.githubusercontent.com/u/21985?v=4)](https://github.com/racklin "racklin (10 commits)")[![sergei-pozniak](https://avatars.githubusercontent.com/u/5438252?v=4)](https://github.com/sergei-pozniak "sergei-pozniak (2 commits)")[![freewill1986](https://avatars.githubusercontent.com/u/7858119?v=4)](https://github.com/freewill1986 "freewill1986 (1 commits)")

---

Tags

laravellaravel-5-packagelaravel5-packagemulti-tenancypostgresqllaravelpostgres

### Embed Badge

![Health badge](/badges/racklin-pgschema/health.svg)

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

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[baril/bonsai

An implementation of the Closure Tables pattern for Eloquent.

3593.5k](/packages/baril-bonsai)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3426.7k](/packages/orptech-laravel-migration-partition)

PHPackages © 2026

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