2024-11-24 05:53:49 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkMigrations;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
|
|
use Doctrine\DBAL\Types\Types;
|
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
|
|
|
|
final class Version20241124112257 extends AbstractMigration
|
|
|
|
{
|
2024-12-02 02:13:20 -06:00
|
|
|
private const string COLUMN_NAME = 'redirect_url';
|
2024-11-24 05:53:49 -06:00
|
|
|
|
|
|
|
public function up(Schema $schema): void
|
|
|
|
{
|
|
|
|
$visits = $schema->getTable('visits');
|
|
|
|
$this->skipIf($visits->hasColumn(self::COLUMN_NAME));
|
|
|
|
|
2024-11-24 06:18:32 -06:00
|
|
|
$visits->addColumn(self::COLUMN_NAME, Types::STRING, [
|
2024-11-24 05:53:49 -06:00
|
|
|
'length' => 2048,
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function down(Schema $schema): void
|
|
|
|
{
|
|
|
|
$visits = $schema->getTable('visits');
|
|
|
|
$this->skipIf(! $visits->hasColumn(self::COLUMN_NAME));
|
|
|
|
$visits->dropColumn(self::COLUMN_NAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isTransactional(): bool
|
|
|
|
{
|
|
|
|
return ! ($this->connection->getDatabasePlatform() instanceof MySQLPlatform);
|
|
|
|
}
|
|
|
|
}
|