@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | throw new Exception("The 'db' option must refer to the application component ID of a DB connection."); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $path = (string)Yii::getAlias($this->migrationPath); |
|
| 92 | + $path = (string) Yii::getAlias($this->migrationPath); |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | if (!is_dir($path)) { |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function getCreateTableSql($table) |
| 186 | 186 | { |
| 187 | - $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->quoteTableName($table->fullName))->queryOne(); |
|
| 187 | + $row = $this->db->createCommand('SHOW CREATE TABLE '.$this->quoteTableName($table->fullName))->queryOne(); |
|
| 188 | 188 | if (isset($row['Create Table'])) { |
| 189 | 189 | $sql = $row['Create Table']; |
| 190 | 190 | } else { |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | public function actionTable(array $tables) |
| 211 | 211 | { |
| 212 | 212 | |
| 213 | - if ($this->confirm('Create the migration ' . "?")) { |
|
| 213 | + if ($this->confirm('Create the migration '."?")) { |
|
| 214 | 214 | |
| 215 | 215 | foreach ($tables as $key => $tableName) { |
| 216 | 216 | |
| 217 | - $this->class = 'create_table_' . $tableName; |
|
| 217 | + $this->class = 'create_table_'.$tableName; |
|
| 218 | 218 | |
| 219 | 219 | try { |
| 220 | 220 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $this->table = $this->getTableName($table); |
| 240 | 240 | |
| 241 | 241 | foreach ($table->columns as $col) { |
| 242 | - $up .= "\t\t\t" . '\'' . $col->name . '\'=>"' . $this->getColType($col) . '",' . "\n"; |
|
| 242 | + $up .= "\t\t\t".'\''.$col->name.'\'=>"'.$this->getColType($col).'",'."\n"; |
|
| 243 | 243 | if ($col->isPrimaryKey) { |
| 244 | 244 | // Add column to composite primary key array |
| 245 | 245 | $compositePrimaryKeyCols[] = $col->name; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | $ukeys = $this->db->schema->findUniqueIndexes($table); |
| 250 | 250 | if (!empty($ukeys)) { |
| 251 | - $indexArr =[]; |
|
| 251 | + $indexArr = []; |
|
| 252 | 252 | foreach ($ukeys as $key => $value) { |
| 253 | 253 | $indexKey = $key; |
| 254 | 254 | foreach ($value as $id => $field) { |
@@ -256,15 +256,15 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | $indexStr = implode(',', $indexArr); |
| 259 | - $up .= "\t\t" . '$this->createIndex(\'idx_' . $indexKey . "', '" . $this->getTableName($table) . "', '$indexStr', TRUE);\n"; |
|
| 259 | + $up .= "\t\t".'$this->createIndex(\'idx_'.$indexKey."', '".$this->getTableName($table)."', '$indexStr', TRUE);\n"; |
|
| 260 | 260 | |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | if (!empty($table->foreignKeys)): |
| 264 | 264 | |
| 265 | 265 | foreach ($table->foreignKeys as $fkName => $fk) { |
| 266 | - $addForeignKeys .= "\t\t" . '$this->addForeignKey("' . $fkName . '", "' . $table->name . '", "' . $fk['column'] . '","' . $fk['table'] . '","' . $fk['ref_column'] . '", "' . $fk['delete'] . '", "' . $fk['update'] . '");' . "\n"; |
|
| 267 | - $dropForeignKeys .= '$this->dropForeignKey(' . "'$fkName', '$table->name');"; |
|
| 266 | + $addForeignKeys .= "\t\t".'$this->addForeignKey("'.$fkName.'", "'.$table->name.'", "'.$fk['column'].'","'.$fk['table'].'","'.$fk['ref_column'].'", "'.$fk['delete'].'", "'.$fk['update'].'");'."\n"; |
|
| 267 | + $dropForeignKeys .= '$this->dropForeignKey('."'$fkName', '$table->name');"; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | endif; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | $fields = $this->parseFields(); |
| 275 | 275 | |
| 276 | - $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields]) . "\n\n"; |
|
| 276 | + $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields])."\n\n"; |
|
| 277 | 277 | |
| 278 | 278 | } |
| 279 | 279 | |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | public function actionData(array $tables) |
| 290 | 290 | { |
| 291 | 291 | |
| 292 | - if ($this->confirm('Create the migration ' . "?", true)) { |
|
| 292 | + if ($this->confirm('Create the migration '."?", true)) { |
|
| 293 | 293 | foreach ($tables as $key => $args) { |
| 294 | 294 | |
| 295 | 295 | $table = $args; |
| 296 | - $this->class = 'insert_data_into_' . $table; |
|
| 296 | + $this->class = 'insert_data_into_'.$table; |
|
| 297 | 297 | $this->table = $table; |
| 298 | 298 | $this->templateFile = '@tmukherjee13/migration/views/dataTemplate.php'; |
| 299 | 299 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | $pcolumns = ''; |
| 323 | 323 | foreach ($columns->columns as $column) { |
| 324 | - $pcolumns .= "'" . $column->name . "',"; |
|
| 324 | + $pcolumns .= "'".$column->name."',"; |
|
| 325 | 325 | } |
| 326 | 326 | foreach ($data as $row) { |
| 327 | 327 | array_push($prepared_data, $row); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | { |
| 354 | 354 | |
| 355 | 355 | $schema = $args; |
| 356 | - $this->class = 'dump_database_' . $schema; |
|
| 356 | + $this->class = 'dump_database_'.$schema; |
|
| 357 | 357 | |
| 358 | 358 | // $tables = $this->db->schema->getTableNames($schema); |
| 359 | 359 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | $generateTables = []; |
| 369 | 369 | |
| 370 | 370 | foreach ($tables as $table) { |
| 371 | - if ($table->name === $this->db->tablePrefix . $this->migrationTable) { |
|
| 371 | + if ($table->name === $this->db->tablePrefix.$this->migrationTable) { |
|
| 372 | 372 | continue; |
| 373 | 373 | } |
| 374 | 374 | $generateTables[] = $table->name; |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | public function getFileName() |
| 382 | 382 | { |
| 383 | - return 'm' . gmdate('ymd_His') . '_' . $this->class; |
|
| 383 | + return 'm'.gmdate('ymd_His').'_'.$this->class; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | public function setFileName() |
@@ -391,9 +391,9 @@ discard block |
||
| 391 | 391 | public function prepareFile($data) |
| 392 | 392 | { |
| 393 | 393 | if ($this->useDataMigrationFolder) { |
| 394 | - FileHelper::createDirectory($this->migrationPath . DIRECTORY_SEPARATOR . $this->dataMigrationFolder); |
|
| 394 | + FileHelper::createDirectory($this->migrationPath.DIRECTORY_SEPARATOR.$this->dataMigrationFolder); |
|
| 395 | 395 | } |
| 396 | - $file = $this->migrationPath . DIRECTORY_SEPARATOR . ($this->useDataMigrationFolder ? $this->dataMigrationFolder . DIRECTORY_SEPARATOR : null) . $this->getFileName() . '.php'; |
|
| 396 | + $file = $this->migrationPath.DIRECTORY_SEPARATOR.($this->useDataMigrationFolder ? $this->dataMigrationFolder.DIRECTORY_SEPARATOR : null).$this->getFileName().'.php'; |
|
| 397 | 397 | try { |
| 398 | 398 | |
| 399 | 399 | $data['table'] = $this->table; |