Conditions | 4 |
Paths | 6 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | public function generate(string $database, array $tables): array |
||
31 | { |
||
32 | $atomizer = new Atomizer(new Renderer()); |
||
33 | |||
34 | $reasonable = false; |
||
35 | foreach ($tables as $table) { |
||
36 | if ($table->getComparator()->hasChanges()) { |
||
37 | $reasonable = true; |
||
38 | $atomizer->addTable($table); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | if (!$reasonable) { |
||
43 | return []; |
||
44 | } |
||
45 | |||
46 | $image = new MigrationImage($this->migrationConfig, $database); |
||
47 | $image->setName($this->nameGenerator->generate($atomizer)); |
||
48 | $image->fileNamePattern = self::$sec++ . '_{database}_{name}'; |
||
49 | |||
50 | $atomizer->declareChanges($image->getClass()->getMethod('up')); |
||
51 | $atomizer->revertChanges($image->getClass()->getMethod('down')); |
||
52 | |||
53 | return [$image]; |
||
54 | } |
||
56 |