| @@ 136-154 (lines=19) @@ | ||
| 133 | * |
|
| 134 | * @SuppressWarnings(PHPMD.ElseExpression) |
|
| 135 | */ |
|
| 136 | private function getMigrations(ContainerInterface $container): Generator |
|
| 137 | { |
|
| 138 | $connection = $this->getConnection($container); |
|
| 139 | $manager = $connection->getSchemaManager(); |
|
| 140 | ||
| 141 | if ($manager->tablesExist([static::MIGRATIONS_TABLE]) === true) { |
|
| 142 | $migrated = $this->readMigrated($connection); |
|
| 143 | } else { |
|
| 144 | $this->createMigrationsTable($manager); |
|
| 145 | $migrated = []; |
|
| 146 | } |
|
| 147 | ||
| 148 | $notYetMigrated = array_diff($this->getMigrationClasses(), $migrated); |
|
| 149 | ||
| 150 | foreach ($notYetMigrated as $class) { |
|
| 151 | yield $class; |
|
| 152 | $this->saveMigration($connection, $class); |
|
| 153 | } |
|
| 154 | } |
|
| 155 | ||
| 156 | /** |
|
| 157 | * @param ContainerInterface $container |
|
| @@ 105-123 (lines=19) @@ | ||
| 102 | * |
|
| 103 | * @SuppressWarnings(PHPMD.ElseExpression) |
|
| 104 | */ |
|
| 105 | protected function getSeeds(ContainerInterface $container): Generator |
|
| 106 | { |
|
| 107 | $connection = $this->getConnection($container); |
|
| 108 | $manager = $connection->getSchemaManager(); |
|
| 109 | ||
| 110 | if ($manager->tablesExist([$this->getSeedsTable()]) === true) { |
|
| 111 | $seeded = $this->readSeeded($connection); |
|
| 112 | } else { |
|
| 113 | $this->createSeedsTable($manager); |
|
| 114 | $seeded = []; |
|
| 115 | } |
|
| 116 | ||
| 117 | $notYetSeeded = array_diff($this->getSeedClasses(), $seeded); |
|
| 118 | ||
| 119 | foreach ($notYetSeeded as $class) { |
|
| 120 | yield $class; |
|
| 121 | $this->saveSeed($connection, $class); |
|
| 122 | } |
|
| 123 | } |
|
| 124 | ||
| 125 | /** |
|
| 126 | * @param ContainerInterface $container |
|