dmstr / yii2-db
数据库扩展
3.0.1
2023-01-24 20:50 UTC
Requires
- php: >=7.1
- mikehaertl/php-shellcommand: 1.*
- schmunk42/retry: *
- yiisoft/yii2: 2.*
- dev-master
- 3.0.1
- 3.0.0
- 3.0.0-rc1
- 3.0.0-beta3
- 3.0.0-beta2
- 3.0.0-beta1
- 2.0.0-rc2
- 2.0.0-rc1
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- 1.0.0-beta1
- 1.0.0-alpha5
- 1.0.0-alpha4
- 1.0.0-alpha3
- 1.0.0-alpha2
- 1.0.0-alpha1
- 0.10.1
- 0.10.0
- 0.10.0-beta3
- 0.10.0-beta2
- 0.10.0-beta1
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.1-rc1
- 0.9.0
- 0.8.11
- 0.8.10
- 0.8.10-rc1
- 0.8.9
- 0.8.8
- 0.8.7
- 0.8.6
- 0.8.5
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.8.0-rc4
- 0.8.0-rc3
- 0.8.0-rc2
- 0.8.0-rc1
- 0.7.8
- 0.7.7
- 0.7.7-rc2
- 0.7.7-rc1
- 0.7.7-beta1
- 0.7.6
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.0
- 0.4.0-beta2
- 0.4.0-beta1
- 0.4.0-alpha1
- 0.3.0
- 0.2.0
- 0.1.1
- 0.1.0
- dev-feature/fix-args
- dev-feature/add-charset-client
- dev-feature/updated-export
- dev-feature/cmd-refactoring
- dev-feature/fix-export-command
- dev-feature/cleanup-and-improvements
- dev-feature/actions
- dev-feature/access-control
- dev-feature/model-import-export
- dev-feature/require
- dev-feature/updated-tests
This package is auto-updated.
Last update: 2024-08-25 00:18:10 UTC
README
关于
dmstr\db\behaviors\HydratedAttributes
检索模型的全部预加载属性,包括关联。一旦扩展安装完毕,只需在代码中通过其全命名空间路径访问相应类即可使用。
dmstr\db\mysql\FileMigration
从sql
文件运行数据库迁移
- 通用数据库扩展
- 预加载属性
- MySQL数据库扩展
- 文件迁移
- MySQL导出/导入控制台控制器
- 从2.0.0版本开始,RBAC迁移已移动至https://github.com/dmstr/yii2-rbac-migration
- 从2.0.0版本开始,活动记录访问类已移动至https://github.com/dmstr/yii2-active-record-permissions
安装
安装此扩展的首选方式是通过composer。
运行
composer require --prefer-dist dmstr/yii2-db "*"
或
"dmstr/yii2-db": "*"
将其添加到您的composer.json
文件的require部分。
配置
dmstr\console\controllers
将其包含在您的控制台配置中
'controllerMap' => [
'db' => [
'class' => 'dmstr\console\controllers\MysqlController',
'noDataTables' => [
'app_log',
'app_session',
]
],
],
使用方法
命令
yii migrate ...
创建文件迁移类
yii migrate/create \
--templateFile='@vendor/dmstr/yii2-db/db/mysql/templates/file-migration.php' init_dump
yii db ...
DESCRIPTION
MySQL database maintenance command for current (db) connection
SUB-COMMANDS
- db/create Create schema
- db/destroy Remove schema
- db/dump Dump schema (all tables)
- db/export Export tables (INSERT only)
- db/import Import from file to database and flush cache
- db/index (default) Displays tables in database
- db/wait-for-connection
To see the detailed information about individual sub-commands, enter:
yii help <sub-command>
显示帮助
yii help db
示例
Dry-run命令(并非所有命令都可用)
yii db/create root secret -n
销毁数据库
yii db/destroy root secret
导出所有表
yii db/dump -o /dumps
从不同的连接导出,排除日志表
yii db/dump -o /dumps \
--db=dbReadonly \
--noDataTables=app_audit_data,app_audit_entry,app_audit_error,app_audit_javascript,app_audit_mail
从辅助连接导出,导入到主连接(默认)
yii db/dump -o /dumps \
--db=dbReadonly \
--noDataTables=app_audit_data,app_audit_entry,app_audit_error,app_audit_javascript,app_audit_mail \
| xargs yii db/import --interactive=0
由dmstr构建