2017 © Pedro Peláez
 

library schemas

image

mobytes/schemas

  • Thursday, December 3, 2015
  • by evervasquez
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel PGSchema

References to https://github.com/pacuna/Laravel-PGSchema@devlaravel4, (*1)

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

Installation

  1. Use composer to add the package into your project using composer require pacuna/schemas:dev-master, (*3)

  2. Add 'Pacuna\Schemas\SchemasServiceProvider' to your app.php file in the services providers section., (*4)

  3. Add 'PGSchema' => 'Pacuna\Schemas\Facades\PGSchema' into the aliases section

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:, (*5)

Create new Schema

PGSchema::create($schemaName), (*6)

Switch to Schema

PGSchema::switchTo($schemaName), (*7)

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

Drop Schema

PGSchema::drop($schemaName), (*9)

Migrate Schema

PGSchema::migrate($schemaName, args[]), (*10)

For example create a migrations in a custom path: php artisan migrate:make create_dogs_table --create=dogs --path=app/database/migrations/foo, (*11)

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

Multi-tenancy Example (SaaS)

Checkout this repo https://github.com/pacuna/laravel-multitenancy-schemas In the handlers folder you can find the code that contains calls to the package., (*13)

Laravel version

Current package version works for Laravel 4.2, (*14)

The Versions

03/12 2015

dev-master

9999999-dev

  Sources   Download

The Requires

 

by eveR Vásquez