|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace DoctrineMigrations; |
| 6 | + |
| 7 | +use Doctrine\DBAL\Schema\Schema; |
| 8 | +use Doctrine\Migrations\AbstractMigration; |
| 9 | + |
| 10 | +/** |
| 11 | + * Scale timestamps to big int for the Year 2038 problem |
| 12 | + */ |
| 13 | +final class Version20250409193948 extends AbstractMigration |
| 14 | +{ |
| 15 | + public function getDescription(): string |
| 16 | + { |
| 17 | + return 'Scale timestamps to big int for the Year 2038 problem'; |
| 18 | + } |
| 19 | + |
| 20 | + public function up(Schema $schema): void |
| 21 | + { |
| 22 | + $this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'This migration is not needed on \'sqlite\'. Skipping it is fine.'); |
| 23 | + |
| 24 | + // MySQL |
| 25 | + if ('mysql' === $this->connection->getDatabasePlatform()->getName()) { |
| 26 | + $this->addSql('ALTER TABLE calendarobjects CHANGE lastmodified lastmodified BIGINT DEFAULT NULL, CHANGE firstoccurence firstoccurence BIGINT DEFAULT NULL, CHANGE lastoccurence lastoccurence BIGINT DEFAULT NULL'); |
| 27 | + $this->addSql('ALTER TABLE calendarsubscriptions CHANGE lastmodified lastmodified BIGINT DEFAULT NULL'); |
| 28 | + $this->addSql('ALTER TABLE locks CHANGE created created BIGINT DEFAULT NULL'); |
| 29 | + $this->addSql('ALTER TABLE schedulingobjects CHANGE lastmodified lastmodified BIGINT DEFAULT NULL'); |
| 30 | + } |
| 31 | + |
| 32 | + // Posgres |
| 33 | + if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) { |
| 34 | + $this->addSql('ALTER TABLE calendarobjects ALTER COLUMN lastmodified TYPE BIGINT'); |
| 35 | + $this->addSql('ALTER TABLE calendarobjects ALTER COLUMN firstoccurence TYPE BIGINT'); |
| 36 | + $this->addSql('ALTER TABLE calendarobjects ALTER COLUMN lastoccurence TYPE BIGINT'); |
| 37 | + $this->addSql('ALTER TABLE calendarsubscriptions ALTER COLUMN lastmodified TYPE BIGINT'); |
| 38 | + $this->addSql('ALTER TABLE locks ALTER COLUMN created TYPE BIGINT'); |
| 39 | + $this->addSql('ALTER TABLE schedulingobjects ALTER COLUMN lastmodified TYPE BIGINT'); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + public function down(Schema $schema): void |
| 44 | + { |
| 45 | + // No need for a down here, it's fine |
| 46 | + } |
| 47 | +} |
0 commit comments