diff --git a/framework/db/Migration.php b/framework/db/Migration.php index 79a5abcf27..0db728fbe6 100644 --- a/framework/db/Migration.php +++ b/framework/db/Migration.php @@ -358,15 +358,15 @@ class Migration extends \yii\base\Component * The method will properly quote the table and column names. * @param string $name the name of the foreign key constraint. * @param string $table the table that the foreign key constraint will be added to. - * @param string $columns the name of the column to that the constraint will be added on. If there are multiple columns, separate them with commas. + * @param string $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. * @param string $refTable the table that the foreign key references to. - * @param string $refColumns the name of the column that the foreign key references to. If there are multiple columns, separate them with commas. + * @param string $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. * @param string $delete the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL * @param string $update the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL */ public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null) { - echo " > add foreign key $name: $table ($columns) references $refTable ($refColumns) ..."; + echo " > add foreign key $name: $table (" . implode(',', (array)$columns) . ") references $refTable (" . implode(',', (array)$refColumns) . ") ..."; $time = microtime(true); $this->db->createCommand()->addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update)->execute(); echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; @@ -390,12 +390,12 @@ class Migration extends \yii\base\Component * @param string $name the name of the index. The name will be properly quoted by the method. * @param string $table the table that the new index will be created for. The table name will be properly quoted by the method. * @param string $column the column(s) that should be included in the index. If there are multiple columns, please separate them - * by commas. The column names will be properly quoted by the method. + * by commas or use an array. The column names will be properly quoted by the method. * @param boolean $unique whether to add UNIQUE constraint on the created index. */ public function createIndex($name, $table, $column, $unique = false) { - echo " > create" . ($unique ? ' unique' : '') . " index $name on $table ($column) ..."; + echo " > create" . ($unique ? ' unique' : '') . " index $name on $table (" . implode(',', (array)$column) . ") ..."; $time = microtime(true); $this->db->createCommand()->createIndex($name, $table, $column, $unique)->execute(); echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";