Completed
Push — master ( 80d6f7...5ed691 )
by Carsten
80:05 queued 69:50
created

Migration::safeDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db;
9
10
use yii\base\Component;
11
use yii\di\Instance;
12
13
/**
14
 * Migration is the base class for representing a database migration.
15
 *
16
 * Migration is designed to be used together with the "yii migrate" command.
17
 *
18
 * Each child class of Migration represents an individual database migration which
19
 * is identified by the child class name.
20
 *
21
 * Within each migration, the [[up()]] method should be overridden to contain the logic
22
 * for "upgrading" the database; while the [[down()]] method for the "downgrading"
23
 * logic. The "yii migrate" command manages all available migrations in an application.
24
 *
25
 * If the database supports transactions, you may also override [[safeUp()]] and
26
 * [[safeDown()]] so that if anything wrong happens during the upgrading or downgrading,
27
 * the whole migration can be reverted in a whole.
28
 *
29
 * Note that some DB queries in some DBMS cannot be put into a transaction. For some examples,
30
 * please refer to [implicit commit](http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html). If this is the case,
31
 * you should still implement `up()` and `down()`, instead.
32
 *
33
 * Migration provides a set of convenient methods for manipulating database data and schema.
34
 * For example, the [[insert()]] method can be used to easily insert a row of data into
35
 * a database table; the [[createTable()]] method can be used to create a database table.
36
 * Compared with the same methods in [[Command]], these methods will display extra
37
 * information showing the method parameters and execution time, which may be useful when
38
 * applying migrations.
39
 *
40
 * For more details and usage information on Migration, see the [guide article on Migration](guide:db-migrations).
41
 *
42
 * @author Qiang Xue <[email protected]>
43
 * @since 2.0
44
 */
45
class Migration extends Component implements MigrationInterface
46
{
47
    use SchemaBuilderTrait;
48
49
    /**
50
     * @var Connection|array|string the DB connection object or the application component ID of the DB connection
51
     * that this migration should work with. Starting from version 2.0.2, this can also be a configuration array
52
     * for creating the object.
53
     *
54
     * Note that when a Migration object is created by the `migrate` command, this property will be overwritten
55
     * by the command. If you do not want to use the DB connection provided by the command, you may override
56
     * the [[init()]] method like the following:
57
     *
58
     * ```php
59
     * public function init()
60
     * {
61
     *     $this->db = 'db2';
62
     *     parent::init();
63
     * }
64
     * ```
65
     */
66
    public $db = 'db';
67
68
69
    /**
70
     * Initializes the migration.
71
     * This method will set [[db]] to be the 'db' application component, if it is `null`.
72
     */
73 19
    public function init()
74
    {
75 19
        parent::init();
76 19
        $this->db = Instance::ensure($this->db, Connection::className());
77 19
        $this->db->getSchema()->refresh();
78 19
        $this->db->enableSlaves = false;
79 19
    }
80
81
    /**
82
     * @inheritdoc
83
     * @since 2.0.6
84
     */
85 7
    protected function getDb()
86
    {
87 7
        return $this->db;
88
    }
89
90
    /**
91
     * This method contains the logic to be executed when applying this migration.
92
     * Child classes may override this method to provide actual migration logic.
93
     * @return bool return a false value to indicate the migration fails
94
     * and should not proceed further. All other return values mean the migration succeeds.
95
     */
96
    public function up()
97
    {
98
        $transaction = $this->db->beginTransaction();
99
        try {
100
            if ($this->safeUp() === false) {
101
                $transaction->rollBack();
102
                return false;
103
            }
104
            $transaction->commit();
105
        } catch (\Exception $e) {
106
            $this->printException($e);
107
            $transaction->rollBack();
108
            return false;
109
        } catch (\Throwable $e) {
0 ignored issues
show
Bug introduced by
The class Throwable does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
110
            $this->printException($e);
111
            $transaction->rollBack();
112
            return false;
113
        }
114
115
        return null;
116
    }
117
118
    /**
119
     * This method contains the logic to be executed when removing this migration.
120
     * The default implementation throws an exception indicating the migration cannot be removed.
121
     * Child classes may override this method if the corresponding migrations can be removed.
122
     * @return bool return a false value to indicate the migration fails
123
     * and should not proceed further. All other return values mean the migration succeeds.
124
     */
125
    public function down()
126
    {
127
        $transaction = $this->db->beginTransaction();
128
        try {
129
            if ($this->safeDown() === false) {
130
                $transaction->rollBack();
131
                return false;
132
            }
133
            $transaction->commit();
134
        } catch (\Exception $e) {
135
            $this->printException($e);
136
            $transaction->rollBack();
137
            return false;
138
        } catch (\Throwable $e) {
0 ignored issues
show
Bug introduced by
The class Throwable does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
139
            $this->printException($e);
140
            $transaction->rollBack();
141
            return false;
142
        }
143
144
        return null;
145
    }
146
147
    /**
148
     * @param \Throwable|\Exception $e
149
     */
150
    private function printException($e)
151
    {
152
        echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n";
153
        echo $e->getTraceAsString() . "\n";
154
    }
155
156
    /**
157
     * This method contains the logic to be executed when applying this migration.
158
     * This method differs from [[up()]] in that the DB logic implemented here will
159
     * be enclosed within a DB transaction.
160
     * Child classes may implement this method instead of [[up()]] if the DB logic
161
     * needs to be within a transaction.
162
     *
163
     * Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples,
164
     * please refer to [implicit commit](http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html). If this is the case,
165
     * you should still implement `up()` and `down()`, instead.
166
     *
167
     * @return bool return a false value to indicate the migration fails
168
     * and should not proceed further. All other return values mean the migration succeeds.
169
     */
170
    public function safeUp()
171
    {
172
    }
173
174
    /**
175
     * This method contains the logic to be executed when removing this migration.
176
     * This method differs from [[down()]] in that the DB logic implemented here will
177
     * be enclosed within a DB transaction.
178
     * Child classes may implement this method instead of [[down()]] if the DB logic
179
     * needs to be within a transaction.
180
     *
181
     * Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples,
182
     * please refer to [implicit commit](http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html). If this is the case,
183
     * you should still implement `up()` and `down()`, instead.
184
     *
185
     * @return bool return a false value to indicate the migration fails
186
     * and should not proceed further. All other return values mean the migration succeeds.
187
     */
188
    public function safeDown()
189
    {
190
    }
191
192
    /**
193
     * Executes a SQL statement.
194
     * This method executes the specified SQL statement using [[db]].
195
     * @param string $sql the SQL statement to be executed
196
     * @param array $params input parameters (name => value) for the SQL execution.
197
     * See [[Command::execute()]] for more details.
198
     */
199
    public function execute($sql, $params = [])
200
    {
201
        echo "    > execute SQL: $sql ...";
202
        $time = microtime(true);
203
        $this->db->createCommand($sql)->bindValues($params)->execute();
204
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
205
    }
206
207
    /**
208
     * Creates and executes an INSERT SQL statement.
209
     * The method will properly escape the column names, and bind the values to be inserted.
210
     * @param string $table the table that new rows will be inserted into.
211
     * @param array $columns the column data (name => value) to be inserted into the table.
212
     */
213
    public function insert($table, $columns)
214
    {
215
        echo "    > insert into $table ...";
216
        $time = microtime(true);
217
        $this->db->createCommand()->insert($table, $columns)->execute();
218
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
219
    }
220
221
    /**
222
     * Creates and executes an batch INSERT SQL statement.
223
     * The method will properly escape the column names, and bind the values to be inserted.
224
     * @param string $table the table that new rows will be inserted into.
225
     * @param array $columns the column names.
226
     * @param array $rows the rows to be batch inserted into the table
227
     */
228
    public function batchInsert($table, $columns, $rows)
229
    {
230
        echo "    > insert into $table ...";
231
        $time = microtime(true);
232
        $this->db->createCommand()->batchInsert($table, $columns, $rows)->execute();
233
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
234
    }
235
236
    /**
237
     * Creates and executes an UPDATE SQL statement.
238
     * The method will properly escape the column names and bind the values to be updated.
239
     * @param string $table the table to be updated.
240
     * @param array $columns the column data (name => value) to be updated.
241
     * @param array|string $condition the conditions that will be put in the WHERE part. Please
242
     * refer to [[Query::where()]] on how to specify conditions.
243
     * @param array $params the parameters to be bound to the query.
244
     */
245
    public function update($table, $columns, $condition = '', $params = [])
246
    {
247
        echo "    > update $table ...";
248
        $time = microtime(true);
249
        $this->db->createCommand()->update($table, $columns, $condition, $params)->execute();
250
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
251
    }
252
253
    /**
254
     * Creates and executes a DELETE SQL statement.
255
     * @param string $table the table where the data will be deleted from.
256
     * @param array|string $condition the conditions that will be put in the WHERE part. Please
257
     * refer to [[Query::where()]] on how to specify conditions.
258
     * @param array $params the parameters to be bound to the query.
259
     */
260
    public function delete($table, $condition = '', $params = [])
261
    {
262
        echo "    > delete from $table ...";
263
        $time = microtime(true);
264
        $this->db->createCommand()->delete($table, $condition, $params)->execute();
265
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
266
    }
267
268
    /**
269
     * Builds and executes a SQL statement for creating a new DB table.
270
     *
271
     * The columns in the new  table should be specified as name-definition pairs (e.g. 'name' => 'string'),
272
     * where name stands for a column name which will be properly quoted by the method, and definition
273
     * stands for the column type which can contain an abstract DB type.
274
     *
275
     * The [[QueryBuilder::getColumnType()]] method will be invoked to convert any abstract type into a physical one.
276
     *
277
     * If a column is specified with definition only (e.g. 'PRIMARY KEY (name, type)'), it will be directly
278
     * put into the generated SQL.
279
     *
280
     * @param string $table the name of the table to be created. The name will be properly quoted by the method.
281
     * @param array $columns the columns (name => definition) in the new table.
282
     * @param string $options additional SQL fragment that will be appended to the generated SQL.
283
     */
284 7
    public function createTable($table, $columns, $options = null)
285
    {
286 7
        echo "    > create table $table ...";
287 7
        $time = microtime(true);
288 7
        $this->db->createCommand()->createTable($table, $columns, $options)->execute();
289 7
        foreach ($columns as $column => $type) {
290 7
            if ($type instanceof ColumnSchemaBuilder && $type->comment !== null) {
291
                $this->db->createCommand()->addCommentOnColumn($table, $column, $type->comment)->execute();
292
            }
293
        }
294 7
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
295 7
    }
296
297
    /**
298
     * Builds and executes a SQL statement for renaming a DB table.
299
     * @param string $table the table to be renamed. The name will be properly quoted by the method.
300
     * @param string $newName the new table name. The name will be properly quoted by the method.
301
     */
302
    public function renameTable($table, $newName)
303
    {
304
        echo "    > rename table $table to $newName ...";
305
        $time = microtime(true);
306
        $this->db->createCommand()->renameTable($table, $newName)->execute();
307
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
308
    }
309
310
    /**
311
     * Builds and executes a SQL statement for dropping a DB table.
312
     * @param string $table the table to be dropped. The name will be properly quoted by the method.
313
     */
314 7
    public function dropTable($table)
315
    {
316 7
        echo "    > drop table $table ...";
317 7
        $time = microtime(true);
318 7
        $this->db->createCommand()->dropTable($table)->execute();
319 7
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
320 7
    }
321
322
    /**
323
     * Builds and executes a SQL statement for truncating a DB table.
324
     * @param string $table the table to be truncated. The name will be properly quoted by the method.
325
     */
326
    public function truncateTable($table)
327
    {
328
        echo "    > truncate table $table ...";
329
        $time = microtime(true);
330
        $this->db->createCommand()->truncateTable($table)->execute();
331
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
332
    }
333
334
    /**
335
     * Builds and executes a SQL statement for adding a new DB column.
336
     * @param string $table the table that the new column will be added to. The table name will be properly quoted by the method.
337
     * @param string $column the name of the new column. The name will be properly quoted by the method.
338
     * @param string $type the column type. The [[QueryBuilder::getColumnType()]] method will be invoked to convert abstract column type (if any)
339
     * into the physical one. Anything that is not recognized as abstract type will be kept in the generated SQL.
340
     * For example, 'string' will be turned into 'varchar(255)', while 'string not null' will become 'varchar(255) not null'.
341
     */
342
    public function addColumn($table, $column, $type)
343
    {
344
        echo "    > add column $column $type to table $table ...";
345
        $time = microtime(true);
346
        $this->db->createCommand()->addColumn($table, $column, $type)->execute();
347
        if ($type instanceof ColumnSchemaBuilder && $type->comment !== null) {
348
            $this->db->createCommand()->addCommentOnColumn($table, $column, $type->comment)->execute();
349
        }
350
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
351
    }
352
353
    /**
354
     * Builds and executes a SQL statement for dropping a DB column.
355
     * @param string $table the table whose column is to be dropped. The name will be properly quoted by the method.
356
     * @param string $column the name of the column to be dropped. The name will be properly quoted by the method.
357
     */
358
    public function dropColumn($table, $column)
359
    {
360
        echo "    > drop column $column from table $table ...";
361
        $time = microtime(true);
362
        $this->db->createCommand()->dropColumn($table, $column)->execute();
363
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
364
    }
365
366
    /**
367
     * Builds and executes a SQL statement for renaming a column.
368
     * @param string $table the table whose column is to be renamed. The name will be properly quoted by the method.
369
     * @param string $name the old name of the column. The name will be properly quoted by the method.
370
     * @param string $newName the new name of the column. The name will be properly quoted by the method.
371
     */
372
    public function renameColumn($table, $name, $newName)
373
    {
374
        echo "    > rename column $name in table $table to $newName ...";
375
        $time = microtime(true);
376
        $this->db->createCommand()->renameColumn($table, $name, $newName)->execute();
377
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
378
    }
379
380
    /**
381
     * Builds and executes a SQL statement for changing the definition of a column.
382
     * @param string $table the table whose column is to be changed. The table name will be properly quoted by the method.
383
     * @param string $column the name of the column to be changed. The name will be properly quoted by the method.
384
     * @param string $type the new column type. The [[QueryBuilder::getColumnType()]] method will be invoked to convert abstract column type (if any)
385
     * into the physical one. Anything that is not recognized as abstract type will be kept in the generated SQL.
386
     * For example, 'string' will be turned into 'varchar(255)', while 'string not null' will become 'varchar(255) not null'.
387
     */
388
    public function alterColumn($table, $column, $type)
389
    {
390
        echo "    > alter column $column in table $table to $type ...";
391
        $time = microtime(true);
392
        $this->db->createCommand()->alterColumn($table, $column, $type)->execute();
393
        if ($type instanceof ColumnSchemaBuilder && $type->comment !== null) {
394
            $this->db->createCommand()->addCommentOnColumn($table, $column, $type->comment)->execute();
395
        }
396
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
397
    }
398
399
    /**
400
     * Builds and executes a SQL statement for creating a primary key.
401
     * The method will properly quote the table and column names.
402
     * @param string $name the name of the primary key constraint.
403
     * @param string $table the table that the primary key constraint will be added to.
404
     * @param string|array $columns comma separated string or array of columns that the primary key will consist of.
405
     */
406
    public function addPrimaryKey($name, $table, $columns)
407
    {
408
        echo "    > add primary key $name on $table (" . (is_array($columns) ? implode(',', $columns) : $columns) . ') ...';
409
        $time = microtime(true);
410
        $this->db->createCommand()->addPrimaryKey($name, $table, $columns)->execute();
411
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
412
    }
413
414
    /**
415
     * Builds and executes a SQL statement for dropping a primary key.
416
     * @param string $name the name of the primary key constraint to be removed.
417
     * @param string $table the table that the primary key constraint will be removed from.
418
     */
419
    public function dropPrimaryKey($name, $table)
420
    {
421
        echo "    > drop primary key $name ...";
422
        $time = microtime(true);
423
        $this->db->createCommand()->dropPrimaryKey($name, $table)->execute();
424
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
425
    }
426
427
    /**
428
     * Builds a SQL statement for adding a foreign key constraint to an existing table.
429
     * The method will properly quote the table and column names.
430
     * @param string $name the name of the foreign key constraint.
431
     * @param string $table the table that the foreign key constraint will be added to.
432
     * @param string|array $columns the name of the column to that the constraint will be added on. If there are multiple columns, separate them with commas or use an array.
433
     * @param string $refTable the table that the foreign key references to.
434
     * @param string|array $refColumns the name of the column that the foreign key references to. If there are multiple columns, separate them with commas or use an array.
435
     * @param string $delete the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
436
     * @param string $update the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
437
     */
438
    public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
439
    {
440
        echo "    > add foreign key $name: $table (" . implode(',', (array) $columns) . ") references $refTable (" . implode(',', (array) $refColumns) . ') ...';
441
        $time = microtime(true);
442
        $this->db->createCommand()->addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update)->execute();
443
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
444
    }
445
446
    /**
447
     * Builds a SQL statement for dropping a foreign key constraint.
448
     * @param string $name the name of the foreign key constraint to be dropped. The name will be properly quoted by the method.
449
     * @param string $table the table whose foreign is to be dropped. The name will be properly quoted by the method.
450
     */
451
    public function dropForeignKey($name, $table)
452
    {
453
        echo "    > drop foreign key $name from table $table ...";
454
        $time = microtime(true);
455
        $this->db->createCommand()->dropForeignKey($name, $table)->execute();
456
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
457
    }
458
459
    /**
460
     * Builds and executes a SQL statement for creating a new index.
461
     * @param string $name the name of the index. The name will be properly quoted by the method.
462
     * @param string $table the table that the new index will be created for. The table name will be properly quoted by the method.
463
     * @param string|array $columns the column(s) that should be included in the index. If there are multiple columns, please separate them
464
     * by commas or use an array. Each column name will be properly quoted by the method. Quoting will be skipped for column names that
465
     * include a left parenthesis "(".
466
     * @param bool $unique whether to add UNIQUE constraint on the created index.
467
     */
468 6
    public function createIndex($name, $table, $columns, $unique = false)
469
    {
470 6
        echo '    > create' . ($unique ? ' unique' : '') . " index $name on $table (" . implode(',', (array) $columns) . ') ...';
471 6
        $time = microtime(true);
472 6
        $this->db->createCommand()->createIndex($name, $table, $columns, $unique)->execute();
473 6
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
474 6
    }
475
476
    /**
477
     * Builds and executes a SQL statement for dropping an index.
478
     * @param string $name the name of the index to be dropped. The name will be properly quoted by the method.
479
     * @param string $table the table whose index is to be dropped. The name will be properly quoted by the method.
480
     */
481
    public function dropIndex($name, $table)
482
    {
483
        echo "    > drop index $name on $table ...";
484
        $time = microtime(true);
485
        $this->db->createCommand()->dropIndex($name, $table)->execute();
486
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
487
    }
488
489
    /**
490
     * Builds and execute a SQL statement for adding comment to column
491
     *
492
     * @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
493
     * @param string $column the name of the column to be commented. The column name will be properly quoted by the method.
494
     * @param string $comment the text of the comment to be added. The comment will be properly quoted by the method.
495
     * @since 2.0.8
496
     */
497
    public function addCommentOnColumn($table, $column, $comment)
498
    {
499
        echo "    > add comment on column $column ...";
500
        $time = microtime(true);
501
        $this->db->createCommand()->addCommentOnColumn($table, $column, $comment)->execute();
502
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
503
    }
504
505
    /**
506
     * Builds a SQL statement for adding comment to table
507
     *
508
     * @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
509
     * @param string $comment the text of the comment to be added. The comment will be properly quoted by the method.
510
     * @since 2.0.8
511
     */
512
    public function addCommentOnTable($table, $comment)
513
    {
514
        echo "    > add comment on table $table ...";
515
        $time = microtime(true);
516
        $this->db->createCommand()->addCommentOnTable($table, $comment)->execute();
517
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
518
    }
519
520
    /**
521
     * Builds and execute a SQL statement for dropping comment from column
522
     *
523
     * @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
524
     * @param string $column the name of the column to be commented. The column name will be properly quoted by the method.
525
     * @since 2.0.8
526
     */
527
    public function dropCommentFromColumn($table, $column)
528
    {
529
        echo "    > drop comment from column $column ...";
530
        $time = microtime(true);
531
        $this->db->createCommand()->dropCommentFromColumn($table, $column)->execute();
532
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
533
    }
534
535
    /**
536
     * Builds a SQL statement for dropping comment from table
537
     *
538
     * @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
539
     * @since 2.0.8
540
     */
541
    public function dropCommentFromTable($table)
542
    {
543
        echo "    > drop comment from table $table ...";
544
        $time = microtime(true);
545
        $this->db->createCommand()->dropCommentFromTable($table)->execute();
546
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
547
    }
548
}
549