2017-10-22 10:00:32 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2017-10-22 10:00:32 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkMigrations;
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
|
|
use Doctrine\DBAL\Schema\SchemaException;
|
|
|
|
use Doctrine\DBAL\Types\Type;
|
2019-03-09 20:45:58 +03:00
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
2017-10-22 10:00:32 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
|
|
*/
|
|
|
|
class Version20171022064541 extends AbstractMigration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @throws SchemaException
|
|
|
|
*/
|
2019-03-09 20:45:58 +03:00
|
|
|
public function up(Schema $schema): void
|
2017-10-22 10:00:32 +03:00
|
|
|
{
|
|
|
|
$shortUrls = $schema->getTable('short_urls');
|
2017-10-23 12:11:26 +03:00
|
|
|
if ($shortUrls->hasColumn('max_visits')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-22 10:00:32 +03:00
|
|
|
$shortUrls->addColumn('max_visits', Type::INTEGER, [
|
|
|
|
'unsigned' => true,
|
|
|
|
'notnull' => false,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws SchemaException
|
|
|
|
*/
|
2019-03-09 20:45:58 +03:00
|
|
|
public function down(Schema $schema): void
|
2017-10-22 10:00:32 +03:00
|
|
|
{
|
|
|
|
$shortUrls = $schema->getTable('short_urls');
|
2017-10-23 12:11:26 +03:00
|
|
|
if (! $shortUrls->hasColumn('max_visits')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-22 10:00:32 +03:00
|
|
|
$shortUrls->dropColumn('max_visits');
|
|
|
|
}
|
|
|
|
}
|