2017-10-21 04:39:27 -05:00
|
|
|
<?php
|
2019-10-05 10:26:10 -05:00
|
|
|
|
2017-10-21 04:39:27 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkMigrations;
|
|
|
|
|
2022-01-10 05:05:01 -06:00
|
|
|
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
2017-10-21 04:39:27 -05:00
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
|
|
use Doctrine\DBAL\Schema\SchemaException;
|
2020-01-06 16:08:14 -06:00
|
|
|
use Doctrine\DBAL\Types\Types;
|
2019-03-09 11:45:58 -06:00
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
2017-10-21 04:39:27 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
|
|
*/
|
|
|
|
class Version20171021093246 extends AbstractMigration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @throws SchemaException
|
|
|
|
*/
|
2019-03-09 11:45:58 -06:00
|
|
|
public function up(Schema $schema): void
|
2017-10-21 04:39:27 -05:00
|
|
|
{
|
|
|
|
$shortUrls = $schema->getTable('short_urls');
|
2017-10-25 09:19:08 -05:00
|
|
|
if ($shortUrls->hasColumn('valid_since')) {
|
2017-10-23 04:11:26 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-07 03:27:35 -06:00
|
|
|
$shortUrls->addColumn('valid_since', Types::DATETIME_MUTABLE, [
|
2017-10-21 04:39:27 -05:00
|
|
|
'notnull' => false,
|
|
|
|
]);
|
2020-11-07 03:27:35 -06:00
|
|
|
$shortUrls->addColumn('valid_until', Types::DATETIME_MUTABLE, [
|
2017-10-21 04:39:27 -05:00
|
|
|
'notnull' => false,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws SchemaException
|
|
|
|
*/
|
2019-03-09 11:45:58 -06:00
|
|
|
public function down(Schema $schema): void
|
2017-10-21 04:39:27 -05:00
|
|
|
{
|
|
|
|
$shortUrls = $schema->getTable('short_urls');
|
2017-10-25 09:19:08 -05:00
|
|
|
if (! $shortUrls->hasColumn('valid_since')) {
|
2017-10-23 04:11:26 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-21 04:39:27 -05:00
|
|
|
$shortUrls->dropColumn('valid_since');
|
|
|
|
$shortUrls->dropColumn('valid_until');
|
|
|
|
}
|
2021-10-23 09:02:29 -05:00
|
|
|
|
|
|
|
public function isTransactional(): bool
|
|
|
|
{
|
2022-01-10 05:05:01 -06:00
|
|
|
return ! ($this->connection->getDatabasePlatform() instanceof MySQLPlatform);
|
2021-10-23 09:02:29 -05:00
|
|
|
}
|
2017-10-21 04:39:27 -05:00
|
|
|
}
|