1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command; |
20
|
|
|
|
21
|
|
|
use Symfony\Component\Console\Command\Command; |
22
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
23
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
24
|
|
|
use Symfony\Component\Process\ProcessBuilder; |
25
|
|
|
|
26
|
|
|
class MigrationsDiffDoctrineCommand extends Command |
27
|
|
|
{ |
28
|
|
|
protected function configure() |
29
|
|
|
{ |
30
|
|
|
$this->setName('middleware:migrations:diff'); |
31
|
|
|
$this->setDescription('Performs a mapping/database diff using the correct entity manager'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
35
|
|
|
{ |
36
|
|
|
$output->writeln(['<info>Generating diff for Middleware...</info>', '']); |
37
|
|
|
|
38
|
|
|
// Cannae run migrations command twice in the same process: registers the migration classes twice with |
39
|
|
|
// Doctrine\DBAL\Migrations\Version. |
40
|
|
|
ProcessBuilder::create( |
41
|
|
|
['app/console', 'doc:mig:diff', '--em=middleware', '--filter-expression=~^(?!event_stream).*$~'] |
42
|
|
|
) |
43
|
|
|
->getProcess() |
44
|
|
|
->run(function ($type, $data) use ($output) { |
45
|
|
|
$output->write($data); |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
// Quick migrations will cause Gateway migrations to overwrite Middleware's as they are identified per second |
49
|
|
|
sleep(1); |
50
|
|
|
|
51
|
|
|
$output->writeln(['<info>Generating diff for Gateway...</info>', '']); |
52
|
|
|
|
53
|
|
|
ProcessBuilder::create(['app/console', 'doc:mig:diff', '--em=gateway']) |
54
|
|
|
->getProcess() |
55
|
|
|
->run(function ($type, $data) use ($output) { |
56
|
|
|
$output->write($data); |
57
|
|
|
}); |
58
|
|
|
|
59
|
|
|
$output->writeln( |
60
|
|
|
'<error>' |
61
|
|
|
.PHP_EOL.PHP_EOL |
62
|
|
|
.' Warning: The Gateway migration diff should be manually edited so' |
63
|
|
|
.' the correct database configuration will be used during migrations!' |
64
|
|
|
.PHP_EOL |
65
|
|
|
.'</error>' |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|