@@ -78,8 +78,8 @@ |
||
78 | 78 | * |
79 | 79 | * @return callable |
80 | 80 | */ |
81 | - protected function getFileSortCallback(){ |
|
82 | - return function ($a, $b) { |
|
81 | + protected function getFileSortCallback() { |
|
82 | + return function($a, $b) { |
|
83 | 83 | return (basename($a) < basename($b)) ? -1 : 1; |
84 | 84 | }; |
85 | 85 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected $schemaProvider; |
45 | 45 | |
46 | - public function __construct(SchemaProviderInterface $schemaProvider=null) |
|
46 | + public function __construct(SchemaProviderInterface $schemaProvider = null) |
|
47 | 47 | { |
48 | 48 | $this->schemaProvider = $schemaProvider; |
49 | 49 | parent::__construct(); |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | $toSchema = $this->getSchemaProvider()->createSchema(); |
91 | 91 | |
92 | 92 | //Not using value from options, because filters can be set from config.yml |
93 | - if ( ! $isDbalOld && $filterExpr = $conn->getConfiguration()->getFilterSchemaAssetsExpression()) { |
|
93 | + if (!$isDbalOld && $filterExpr = $conn->getConfiguration()->getFilterSchemaAssetsExpression()) { |
|
94 | 94 | foreach ($toSchema->getTables() as $table) { |
95 | 95 | $tableName = $table->getName(); |
96 | - if ( ! preg_match($filterExpr, $this->resolveTableName($tableName))) { |
|
96 | + if (!preg_match($filterExpr, $this->resolveTableName($tableName))) { |
|
97 | 97 | $toSchema->dropTable($tableName); |
98 | 98 | } |
99 | 99 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $up = $this->buildCodeFromSql($configuration, $fromSchema->getMigrateToSql($toSchema, $platform)); |
103 | 103 | $down = $this->buildCodeFromSql($configuration, $fromSchema->getMigrateFromSql($toSchema, $platform)); |
104 | 104 | |
105 | - if (! $up && ! $down) { |
|
105 | + if (!$up && !$down) { |
|
106 | 106 | $output->writeln('No changes detected in your mapping information.', 'ERROR'); |
107 | 107 | |
108 | 108 | return; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $this->configuration = $this->getMigrationConfiguration($input, $output); |
94 | 94 | |
95 | - if ( ! $input->getOption('add') && ! $input->getOption('delete')) { |
|
95 | + if (!$input->getOption('add') && !$input->getOption('delete')) { |
|
96 | 96 | throw new \InvalidArgumentException('You must specify whether you want to --add or --delete the specified version.'); |
97 | 97 | } |
98 | 98 | |
@@ -147,26 +147,26 @@ discard block |
||
147 | 147 | |
148 | 148 | private function mark($version, $all = false) |
149 | 149 | { |
150 | - if ( ! $this->configuration->hasVersion($version)) { |
|
150 | + if (!$this->configuration->hasVersion($version)) { |
|
151 | 151 | throw MigrationException::unknownMigrationVersion($version); |
152 | 152 | } |
153 | 153 | |
154 | 154 | $version = $this->configuration->getVersion($version); |
155 | 155 | if ($this->markMigrated && $this->configuration->hasVersionMigrated($version)) { |
156 | 156 | $marked = true; |
157 | - if (! $all) { |
|
157 | + if (!$all) { |
|
158 | 158 | throw new \InvalidArgumentException(sprintf('The version "%s" already exists in the version table.', $version)); |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - if ( ! $this->markMigrated && ! $this->configuration->hasVersionMigrated($version)) { |
|
162 | + if (!$this->markMigrated && !$this->configuration->hasVersionMigrated($version)) { |
|
163 | 163 | $marked = false; |
164 | - if (! $all) { |
|
164 | + if (!$all) { |
|
165 | 165 | throw new \InvalidArgumentException(sprintf('The version "%s" does not exists in the version table.', $version)); |
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | - if ( ! isset($marked)) { |
|
169 | + if (!isset($marked)) { |
|
170 | 170 | if ($this->markMigrated) { |
171 | 171 | $version->markMigrated(); |
172 | 172 | } else { |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | $question = 'Are you sure you wish to continue? (y/n)'; |
117 | - if (! $this->canExecute($question, $input, $output)) { |
|
117 | + if (!$this->canExecute($question, $input, $output)) { |
|
118 | 118 | $output->writeln('<error>Migration cancelled!</error>'); |
119 | 119 | |
120 | 120 | return 1; |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | $dryRun = (boolean) $input->getOption('dry-run'); |
129 | 129 | |
130 | 130 | // warn the user if no dry run and interaction is on |
131 | - if (! $dryRun) { |
|
131 | + if (!$dryRun) { |
|
132 | 132 | $question = 'WARNING! You are about to execute a database migration' |
133 | 133 | . ' that could result in schema changes and data lost.' |
134 | 134 | . ' Are you sure you wish to continue? (y/n)'; |
135 | - if (! $this->canExecute($question, $input, $output)) { |
|
135 | + if (!$this->canExecute($question, $input, $output)) { |
|
136 | 136 | $output->writeln('<error>Migration cancelled!</error>'); |
137 | 137 | |
138 | 138 | return 1; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function canExecute($question, InputInterface $input, OutputInterface $output) |
158 | 158 | { |
159 | - if ($input->isInteractive() && ! $this->askConfirmation($question, $input, $output)) { |
|
159 | + if ($input->isInteractive() && !$this->askConfirmation($question, $input, $output)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'Next Version' => $formattedVersions['next'], |
97 | 97 | 'Latest Version' => $formattedVersions['latest'], |
98 | 98 | 'Executed Migrations' => count($executedMigrations), |
99 | - 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations > 0 ? '<error>'.$numExecutedUnavailableMigrations.'</error>' : 0, |
|
99 | + 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations > 0 ? '<error>' . $numExecutedUnavailableMigrations . '</error>' : 0, |
|
100 | 100 | 'Available Migrations' => count($availableMigrations), |
101 | 101 | 'New Migrations' => $newMigrations > 0 ? '<question>' . $newMigrations . '</question>' : 0 |
102 | 102 | ]; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | $migratedVersions = $configuration->getMigratedVersions(); |
125 | 125 | |
126 | - foreach($migrations as $version) { |
|
126 | + foreach ($migrations as $version) { |
|
127 | 127 | $isMigrated = in_array($version->getVersion(), $migratedVersions); |
128 | 128 | $status = $isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>'; |
129 | 129 | $migrationDescription = ''; |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | |
135 | 135 | $output->writeln(' <comment>>></comment> ' . $formattedVersion . |
136 | 136 | ' (<comment>' . $version->getVersion() . '</comment>)' . |
137 | - str_repeat(' ', 49 - strlen($formattedVersion) - strlen($version->getVersion())) . |
|
138 | - $status . $migrationDescription); |
|
137 | + str_repeat(' ', 49 - strlen($formattedVersion) - strlen($version->getVersion())) . |
|
138 | + $status . $migrationDescription); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | } |
@@ -122,6 +122,9 @@ |
||
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | + /** |
|
126 | + * @param \Doctrine\DBAL\Migrations\Version[] $migrations |
|
127 | + */ |
|
125 | 128 | private function showVersions($migrations, Configuration $configuration, OutputInterface $output) |
126 | 129 | { |
127 | 130 | $migratedVersions = $configuration->getMigratedVersions(); |
@@ -60,7 +60,7 @@ |
||
60 | 60 | |
61 | 61 | protected function setConfiguration(Array $config) |
62 | 62 | { |
63 | - foreach($config as $configurationKey => $configurationValue) { |
|
63 | + foreach ($config as $configurationKey => $configurationValue) { |
|
64 | 64 | if (!isset($this->configurationProperties[$configurationKey])) { |
65 | 65 | $msg = sprintf('Migrations configuration key "%s" does not exists.', $configurationKey); |
66 | 66 | throw MigrationException::configurationNotValid($msg); |
@@ -787,7 +787,7 @@ |
||
787 | 787 | */ |
788 | 788 | private function ensureMigrationClassExists($class) |
789 | 789 | { |
790 | - if ( ! class_exists($class)) { |
|
790 | + if (!class_exists($class)) { |
|
791 | 791 | throw MigrationException::migrationClassNotFound($class, $this->getMigrationsNamespace()); |
792 | 792 | } |
793 | 793 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $this->migration->{'post' . ucfirst($direction)}($toSchema); |
271 | 271 | $this->executeRegisteredSql($dryRun, $timeAllQueries); |
272 | 272 | |
273 | - if (! $dryRun) { |
|
273 | + if (!$dryRun) { |
|
274 | 274 | if ($direction === self::DIRECTION_UP) { |
275 | 275 | $this->markMigrated(); |
276 | 276 | } else { |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | - $this->outputWriter->write(sprintf("\n <info>SS</info> skipped (Reason: %s)", $e->getMessage())); |
|
312 | + $this->outputWriter->write(sprintf("\n <info>SS</info> skipped (Reason: %s)", $e->getMessage())); |
|
313 | 313 | |
314 | 314 | $this->state = self::STATE_NONE; |
315 | 315 | |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | |
373 | 373 | private function executeRegisteredSql($dryRun = false, $timeAllQueries = false) |
374 | 374 | { |
375 | - if (! $dryRun) { |
|
375 | + if (!$dryRun) { |
|
376 | 376 | if (!empty($this->sql)) { |
377 | 377 | foreach ($this->sql as $key => $query) { |
378 | 378 | $queryStart = microtime(true); |
379 | 379 | |
380 | - if ( ! isset($this->params[$key])) { |
|
380 | + if (!isset($this->params[$key])) { |
|
381 | 381 | $this->outputWriter->write(' <comment>-></comment> ' . $query); |
382 | 382 | $this->connection->exec($query); |
383 | 383 | } else { |
@@ -105,6 +105,10 @@ discard block |
||
105 | 105 | */ |
106 | 106 | private $state = self::STATE_NONE; |
107 | 107 | |
108 | + /** |
|
109 | + * @param string $version |
|
110 | + * @param string $class |
|
111 | + */ |
|
108 | 112 | public function __construct(Configuration $configuration, $version, $class) |
109 | 113 | { |
110 | 114 | $this->configuration = $configuration; |
@@ -198,7 +202,7 @@ discard block |
||
198 | 202 | * @param string $path The path to write the migration SQL file. |
199 | 203 | * @param string $direction The direction to execute. |
200 | 204 | * |
201 | - * @return boolean $written |
|
205 | + * @return integer $written |
|
202 | 206 | */ |
203 | 207 | public function writeSqlFile($path, $direction = self::DIRECTION_UP) |
204 | 208 | { |
@@ -348,6 +352,9 @@ discard block |
||
348 | 352 | } |
349 | 353 | } |
350 | 354 | |
355 | + /** |
|
356 | + * @param double $queryStart |
|
357 | + */ |
|
351 | 358 | private function outputQueryTime($queryStart, $timeAllQueries = false) |
352 | 359 | { |
353 | 360 | if ($timeAllQueries !== false) { |
@@ -361,7 +368,7 @@ discard block |
||
361 | 368 | /** |
362 | 369 | * Returns the time this migration version took to execute |
363 | 370 | * |
364 | - * @return integer $time The time this migration version took to execute |
|
371 | + * @return double $time The time this migration version took to execute |
|
365 | 372 | */ |
366 | 373 | public function getTime() |
367 | 374 | { |