mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-27 16:26:37 +03:00
Updated casting type so that it is dynamic
This commit is contained in:
parent
37f0abf86f
commit
96bb0321eb
1 changed files with 7 additions and 1 deletions
|
@ -56,12 +56,18 @@ final class Version20200105165647 extends AbstractMigration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws DBALException
|
||||||
|
*/
|
||||||
public function postUp(Schema $schema): void
|
public function postUp(Schema $schema): void
|
||||||
{
|
{
|
||||||
|
$platformName = $this->connection->getDatabasePlatform()->getName();
|
||||||
|
$castType = $platformName === 'postgres' ? 'DOUBLE PRECISION' : 'DECIMAL(9,2)';
|
||||||
|
|
||||||
foreach (self::COLUMNS as $newName => $oldName) {
|
foreach (self::COLUMNS as $newName => $oldName) {
|
||||||
$qb = $this->connection->createQueryBuilder();
|
$qb = $this->connection->createQueryBuilder();
|
||||||
$qb->update('visit_locations')
|
$qb->update('visit_locations')
|
||||||
->set($newName, 'CAST(' . $oldName . ' AS DOUBLE PRECISION)')
|
->set($newName, 'CAST(' . $oldName . ' AS ' . $castType . ')')
|
||||||
->execute();
|
->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue