racklin / pgschema
为 Laravel 5 提供的 PostgreSQL 模式
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 auto-updated.
Last update: 2024-09-04 18:24:00 UTC
README
当您在 PostgreSQL 模式中与多租户应用程序一起工作时,这非常有用。
使用外观辅助函数,您可以轻松地创建/删除/切换模式。此包还提供了为每个模式支持迁移和种子的人工智能命令。
PGSchema 将检查并仅在特定连接驱动程序为 pgsql
时产生影响。因此,您可以安全地将 PGSchema 用于您的项目,而无需任何数据库连接驱动程序错误。
Laravel 版本
当前包版本适用于 Laravel 5+
.
安装
- 使用 composer 将包添加到您的项目中
composer require racklin/pgschema:dev-master
- 在
config/app.php
中的 providers 数组中添加服务提供者
Racklin\PGSchema\PGSchemaServiceProvider::class,
- 在
config/app.php
中的 aliases 数组中添加别名
'PGSchema' => Racklin\PGSchema\Facades\PGSchema::class,
人工智能命令
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 参数,它将使用默认连接。