From e282521040508fd8f4d63686dbf414e24d21a86f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 23 Oct 2017 11:11:26 +0200 Subject: [PATCH] Updated migrations to prevent duplication when running after orm schema tool --- data/migrations/Version20171021093246.php | 8 ++++++++ data/migrations/Version20171022064541.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/data/migrations/Version20171021093246.php b/data/migrations/Version20171021093246.php index a9c39ebb..d0aff69b 100644 --- a/data/migrations/Version20171021093246.php +++ b/data/migrations/Version20171021093246.php @@ -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'); } diff --git a/data/migrations/Version20171022064541.php b/data/migrations/Version20171022064541.php index bac05c61..ef0447aa 100644 --- a/data/migrations/Version20171022064541.php +++ b/data/migrations/Version20171022064541.php @@ -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'); } }