@@ -8,6 +8,16 @@ Yii 2 Database Toolkit
88About
99-----
1010
11+
12+ ### [ dmstr\db\behaviors\HydratedAttributes] ( https://github.com/dmstr/yii2-db/blob/master/db/behaviors/HydratedAttributes.php )
13+
14+ 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.
15+
16+ ### [ dmstr\db\mysql\FileMigration] ( https://github.com/dmstr/yii2-db/blob/master/db/mysql/FileMigration.php )
17+
18+ runs database migrations from ` sql ` files
19+
20+
1121- Generic database exentsions
1222 - Hydrated Attributes
1323- Database extensions for MySQL
@@ -25,7 +35,7 @@ The preferred way to install this extension is through [composer](http://getcomp
2535Either run
2636
2737```
28- php composer.phar require --prefer-dist dmstr/yii2-db "*"
38+ composer require --prefer-dist dmstr/yii2-db "*"
2939```
3040
3141or add
@@ -36,87 +46,109 @@ or add
3646
3747to the require section of your ` composer.json ` file.
3848
39- Commands
40- --------
49+ Configuration
50+ -------------
51+
52+ ### [ dmstr\console\controllers] ( https://github.com/dmstr/yii2-db/blob/master/console/controllers )
53+
54+ Include it in your console configuration
55+
56+ ```
57+ 'controllerMap' => [
58+ 'db' => [
59+ 'class' => 'dmstr\console\controllers\MysqlController',
60+ 'noDataTables' => [
61+ 'app_log',
62+ 'app_session',
63+ ]
64+ ],
65+ ],
66+ ```
67+
68+ Usage
69+ -----
70+
71+ ### Commands
4172
42- ### ` yii db `
73+ #### ` yii migrate ... `
74+
75+ Create a file migration class
76+
77+ ```
78+ yii migrate/create \
79+ --templateFile='@vendor/dmstr/yii2-db/db/mysql/templates/file-migration.php' init_dump
80+ ```
81+
82+
83+ #### ` yii db ... `
4384
4485```
4586DESCRIPTION
4687
47- MySQL database maintenance command.
88+ MySQL database maintenance command for current (db) connection
4889
4990
5091SUB-COMMANDS
5192
52- - db/create Create MySQL database
53- - db/destroy Remove the current schema
54- - db/dump Dumps current database tables to runtime folder
55- - db/export export data tables, without logs and caches
56- - db/import
93+ - db/create Create schema
94+ - db/destroy Remove schema
95+ - db/dump Dump schema (all tables)
96+ - db/export Export tables (INSERT only)
97+ - db/import Import from file to database and flush cache
5798- db/index (default) Displays tables in database
5899- db/wait-for-connection
59100
60101To see the detailed information about individual sub-commands, enter:
61102
62103 yii help <sub-command>
104+
63105```
64106
65107
66- Usage
67- -----
68-
69- ### [ dmstr\db\behaviors\HydratedAttributes] ( https://github.com/dmstr/yii2-db/blob/master/db/behaviors/HydratedAttributes.php )
108+ Show help
70109
71- 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.
110+ ```
111+ yii help db
112+ ```
72113
73- ### [ dmstr\db\mysql\FileMigration] ( https://github.com/dmstr/yii2-db/blob/master/db/mysql/FileMigration.php )
74114
75- runs database migrations from ` sql ` files
115+ ### Examples
76116
77- Create a file migration class
117+ Dry-run command (not available for all commands)
78118
79119```
80- ./yii migrate/create \
81- --templateFile='@vendor/dmstr/yii2-db/db/mysql/templates/file-migration.php' init_dump
120+ yii db/create root secret -n
82121```
83122
84- ### [ dmstr\console\controllers] ( https://github.com/dmstr/yii2-db/blob/master/console/controllers )
85-
86- Include it in your console configuration
123+ Destroy database
87124
88125```
89- 'controllerMap' => [
90- 'db' => [
91- 'class' => 'dmstr\console\controllers\MysqlController',
92- 'noDataTables' => [
93- 'app_log',
94- 'app_session',
95- ]
96- ],
97- ],
126+ yii db/destroy root secret
98127```
99128
100- Show help
129+ Dump all tables
101130
102131```
103- ./yii help db
104- ```
105-
106- Available commands
107-
132+ yii db/dump -o /dumps
108133```
109- DESCRIPTION
110134
111- MySQL database maintenance command.
135+ Dump from different connection, exclude logging tables
112136
137+ ```
138+ yii db/dump -o /dumps \
139+ --db=dbReadonly \
140+ --noDataTables=app_audit_data,app_audit_entry,app_audit_error,app_audit_javascript,app_audit_mail
141+ ```
113142
114- SUB-COMMANDS
143+ Dump from secondary connection, import into primary (default)
115144
116- - db/create Create MySQL database from ENV vars and grant permissions
117- - db/dump Dumps current database tables to runtime folder
118- - db/index (default) Displays tables in database
119145```
146+ yii db/dump -o /dumps \
147+ --db=dbReadonly \
148+ --noDataTables=app_audit_data,app_audit_entry,app_audit_error,app_audit_javascript,app_audit_mail \
149+ | xargs yii db/import --interactive=0
150+ ```
151+
120152
121153---
122154
0 commit comments