Package Data | |
---|---|
Maintainer Username: | pacuna |
Maintainer Contact: | pabloacuna88@gmail.com (Pablo Acuña) |
Package Create Date: | 2014-01-06 |
Package Last Update: | 2018-09-05 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-20 03:01:31 |
Package Statistics | |
---|---|
Total Downloads: | 65,385 |
Monthly Downloads: | 54 |
Daily Downloads: | 4 |
Total Stars: | 42 |
Total Watchers: | 6 |
Total Forks: | 20 |
Total Open Issues: | 4 |
[LOOKING FOR MAINTAINER]
Please contact me if you are interested in maintaining this library. I no longer work with Laravel so I'm not able to keep up with the updates.
With this package you can create, switch and drop postgresql schemas easily. This is very useful when you are working with multi-tenants applications.
Use composer to add the package into your project
using
composer require pacuna/schemas:dev-master
Add 'Pacuna\Schemas\SchemasServiceProvider' to your app.php file in the services providers section.
Add 'PGSchema' => 'Pacuna\Schemas\Facades\PGSchema' into the aliases section
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:
PGSchema::create($schemaName)
PGSchema::switchTo($schemaName)
if switchTo is call without arguments, it switches to the public schema (default)
PGSchema::drop($schemaName)
PGSchema::migrate($schemaName, args[])
For example create a migrations in a custom path:
php artisan migrate:make create_dogs_table --create=dogs --path=app/database/migrations/foo
Then you can migrate some schema using this path
PGSchema::migrate($schemaName, ['--path' => 'app/database/migrations/foo'])
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.
Current package version works for Laravel 5. If you need Laravel 4 support checkout for the laravel4 branch.