dmstr / yii2-db
Database extensions
Installs: 521 803
Dependents: 9
Suggesters: 0
Security: 0
Stars: 19
Watchers: 11
Forks: 9
Open Issues: 1
Type:yii2-extension
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-10-25 00:46:57 UTC
README
About
dmstr\db\behaviors\HydratedAttributes
Retrieves all eager loaded attributes of a model including relations. Once the extension is installed, simply use it in your code by accessing the corresponding classes by their full namespaced path.
dmstr\db\mysql\FileMigration
runs database migrations from sql
files
- Generic database exentsions
- Hydrated Attributes
- Database extensions for MySQL
- File Migration
- Mysql dump/export/import console controller
- RBAC migrations moved to https://github.com/dmstr/yii2-rbac-migration since 2.0.0
- Active record access classes moved to https://github.com/dmstr/yii2-active-record-permissions since 2.0.0
Installation
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist dmstr/yii2-db "*"
or add
"dmstr/yii2-db": "*"
to the require section of your composer.json
file.
Configuration
dmstr\console\controllers
Include it in your console configuration
'controllerMap' => [
'db' => [
'class' => 'dmstr\console\controllers\MysqlController',
'noDataTables' => [
'app_log',
'app_session',
]
],
],
Usage
Commands
yii migrate ...
Create a file migration class
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>
Show help
yii help db
Examples
Dry-run command (not available for all commands)
yii db/create root secret -n
Destroy database
yii db/destroy root secret
Dump all tables
yii db/dump -o /dumps
Dump from different connection, exclude logging tables
yii db/dump -o /dumps \
--db=dbReadonly \
--noDataTables=app_audit_data,app_audit_entry,app_audit_error,app_audit_javascript,app_audit_mail
Dump from secondary connection, import into primary (default)
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
Built by dmstr