'country_code', 'countryName' => 'country_name', 'regionName' => 'region_name', 'cityName' => 'city_name', ]; /** * @param Schema $schema * @throws SchemaException */ public function up(Schema $schema): void { $this->createColumns($schema->getTable('visit_locations'), self::COLUMNS); } private function createColumns(Table $visitLocations, array $columnNames): void { foreach ($columnNames as $name) { if (! $visitLocations->hasColumn($name)) { $visitLocations->addColumn($name, Type::STRING, ['notnull' => false]); } } } /** * @throws SchemaException * @throws DBALException */ public function postUp(Schema $schema): void { $visitLocations = $schema->getTable('visit_locations'); // If the camel case columns do not exist, do nothing if (! $visitLocations->hasColumn('countryCode')) { return; } $qb = $this->connection->createQueryBuilder(); $qb->update('visit_locations'); foreach (self::COLUMNS as $camelCaseName => $snakeCaseName) { $qb->set($snakeCaseName, $camelCaseName); } $qb->execute(); } public function down(Schema $schema): void { // No down } }