jinjian / pgschema
PostgreSQL schema for Laravel
Requires
- php: >=7.0.0
- illuminate/console: ~5.5 || ^6.0
- illuminate/database: ~5.5 || ^6.0
- illuminate/support: ~5.5 || ^6.0
This package is not auto-updated.
Last update: 2024-09-27 02:26:32 UTC
README
当您与具有 PostgreSQL Schema 的多租户应用程序一起工作时,这非常有用。
使用外观辅助函数,您可以轻松地创建/删除/切换模式。此包还提供了 artisan 命令,用于对每个模式进行迁移和种子支持。
PGSchema 将检查并仅在特定连接驱动程序为 pgsql
时产生影响。因此,您可以使用 PGSchema 在任何数据库连接驱动程序的项目中安全地使用,而不会发生错误。
Laravel 版本
当前包版本适用于 Laravel 5+
。
安装
- 使用 composer 将包添加到您的项目中
composer require jinjian/pgschema:dev-master
- 在
config/app.php
中的 providers 数组中添加服务提供者
Rock\PGSchema\PGSchemaServiceProvider::class,
- 在
config/app.php
中的 aliases 数组中添加别名
'PGSchema' => Rock\PGSchema\Facades\PGSchema::class,
Artisan 命令
pgschema:migrate
pgschema:migrate
命令向 Laravel migrate
命令添加额外的 schema
选项,您可以指定迁移的数据库模式。并且它将为该模式自动安装 migrations
存储库表。
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
pgschema:rollback
命令向 Laravel migrate:rollback
命令添加额外的 schema
选项。
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
pgschema:reset
命令向 Laravel migrate:reset
命令添加额外的 schema
选项。
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
pgschema:refresh
命令向 Laravel migrate:refresh
命令添加额外的 schema
选项。
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
pgschema:seed
命令向 Laravel db:seed
命令添加额外的 schema
选项。
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
pgschema:create-schema
为 database
创建 schema
。
Usage:
pgschema:create-schema [options] [--] <schema>
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
外观辅助函数
创建新模式
PGSchema::create($schemaName, $databaseName)
如果没有提供 $databaseName 参数,则使用默认连接。
删除模式
PGSchema::drop($schemaName, $databaseName)
如果没有提供 $databaseName 参数,则使用默认连接。
切换模式
PGSchema::schema($schemaName, $databaseName)
如果没有提供 $schemaName 参数,则切换到公共模式(默认)。如果没有提供 $databaseName 参数,则使用默认连接。
遍历模式
PGSchema::each(Closure $callback, $databaseName)
如果没有提供 $databaseName 参数,则使用默认连接。