shlink/data/migrations/Version20171021093246.php

55 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2019-10-05 18:26:10 +03:00
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Types;
2019-03-09 20:45:58 +03:00
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20171021093246 extends AbstractMigration
{
/**
* @throws SchemaException
*/
2019-03-09 20:45:58 +03:00
public function up(Schema $schema): void
{
$shortUrls = $schema->getTable('short_urls');
2017-10-25 17:19:08 +03:00
if ($shortUrls->hasColumn('valid_since')) {
return;
}
$shortUrls->addColumn('valid_since', Types::DATETIME_MUTABLE, [
'notnull' => false,
]);
$shortUrls->addColumn('valid_until', Types::DATETIME_MUTABLE, [
'notnull' => false,
]);
}
/**
* @throws SchemaException
*/
2019-03-09 20:45:58 +03:00
public function down(Schema $schema): void
{
$shortUrls = $schema->getTable('short_urls');
2017-10-25 17:19:08 +03:00
if (! $shortUrls->hasColumn('valid_since')) {
return;
}
$shortUrls->dropColumn('valid_since');
$shortUrls->dropColumn('valid_until');
}
public function isTransactional(): bool
{
return ! ($this->connection->getDatabasePlatform() instanceof MySQLPlatform);
}
}