Updated migrations to prevent duplication when running after orm schema tool

This commit is contained in:
Alejandro Celaya 2017-10-23 11:11:26 +02:00
parent d7b7db670f
commit e282521040
2 changed files with 16 additions and 0 deletions

View File

@ -20,6 +20,10 @@ class Version20171021093246 extends AbstractMigration
public function up(Schema $schema)
{
$shortUrls = $schema->getTable('short_urls');
if ($shortUrls->hasColumn('value_since')) {
return;
}
$shortUrls->addColumn('valid_since', Type::DATETIME, [
'notnull' => false,
]);
@ -35,6 +39,10 @@ class Version20171021093246 extends AbstractMigration
public function down(Schema $schema)
{
$shortUrls = $schema->getTable('short_urls');
if (! $shortUrls->hasColumn('value_since')) {
return;
}
$shortUrls->dropColumn('valid_since');
$shortUrls->dropColumn('valid_until');
}

View File

@ -20,6 +20,10 @@ class Version20171022064541 extends AbstractMigration
public function up(Schema $schema)
{
$shortUrls = $schema->getTable('short_urls');
if ($shortUrls->hasColumn('max_visits')) {
return;
}
$shortUrls->addColumn('max_visits', Type::INTEGER, [
'unsigned' => true,
'notnull' => false,
@ -33,6 +37,10 @@ class Version20171022064541 extends AbstractMigration
public function down(Schema $schema)
{
$shortUrls = $schema->getTable('short_urls');
if (! $shortUrls->hasColumn('max_visits')) {
return;
}
$shortUrls->dropColumn('max_visits');
}
}