2021-02-02 13:21:48 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkMigrations;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
|
|
use Doctrine\DBAL\Types\Types;
|
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
|
|
|
|
final class Version20210202181026 extends AbstractMigration
|
|
|
|
{
|
|
|
|
private const TITLE = 'title';
|
|
|
|
|
|
|
|
public function up(Schema $schema): void
|
|
|
|
{
|
|
|
|
$shortUrls = $schema->getTable('short_urls');
|
|
|
|
$this->skipIf($shortUrls->hasColumn(self::TITLE));
|
|
|
|
|
|
|
|
$shortUrls->addColumn(self::TITLE, Types::STRING, [
|
|
|
|
'notnull' => false,
|
|
|
|
'length' => 512,
|
|
|
|
]);
|
2021-02-03 12:22:47 -06:00
|
|
|
$shortUrls->addColumn('title_was_auto_resolved', Types::BOOLEAN, [
|
|
|
|
'default' => false,
|
|
|
|
]);
|
2021-02-02 13:21:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
public function down(Schema $schema): void
|
|
|
|
{
|
|
|
|
$shortUrls = $schema->getTable('short_urls');
|
|
|
|
$this->skipIf(! $shortUrls->hasColumn(self::TITLE));
|
|
|
|
$shortUrls->dropColumn(self::TITLE);
|
2021-02-03 12:22:47 -06:00
|
|
|
$shortUrls->dropColumn('title_was_auto_resolved');
|
|
|
|
}
|
2021-10-23 09:02:29 -05:00
|
|
|
|
|
|
|
public function isTransactional(): bool
|
|
|
|
{
|
|
|
|
return $this->connection->getDatabasePlatform()->getName() !== 'mysql';
|
|
|
|
}
|
2021-02-02 13:21:48 -06:00
|
|
|
}
|