mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 23:23:42 -06:00
Updated migrations to prevent duplication when running after orm schema tool
This commit is contained in:
parent
d7b7db670f
commit
e282521040
@ -20,6 +20,10 @@ class Version20171021093246 extends AbstractMigration
|
|||||||
public function up(Schema $schema)
|
public function up(Schema $schema)
|
||||||
{
|
{
|
||||||
$shortUrls = $schema->getTable('short_urls');
|
$shortUrls = $schema->getTable('short_urls');
|
||||||
|
if ($shortUrls->hasColumn('value_since')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$shortUrls->addColumn('valid_since', Type::DATETIME, [
|
$shortUrls->addColumn('valid_since', Type::DATETIME, [
|
||||||
'notnull' => false,
|
'notnull' => false,
|
||||||
]);
|
]);
|
||||||
@ -35,6 +39,10 @@ class Version20171021093246 extends AbstractMigration
|
|||||||
public function down(Schema $schema)
|
public function down(Schema $schema)
|
||||||
{
|
{
|
||||||
$shortUrls = $schema->getTable('short_urls');
|
$shortUrls = $schema->getTable('short_urls');
|
||||||
|
if (! $shortUrls->hasColumn('value_since')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$shortUrls->dropColumn('valid_since');
|
$shortUrls->dropColumn('valid_since');
|
||||||
$shortUrls->dropColumn('valid_until');
|
$shortUrls->dropColumn('valid_until');
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,10 @@ class Version20171022064541 extends AbstractMigration
|
|||||||
public function up(Schema $schema)
|
public function up(Schema $schema)
|
||||||
{
|
{
|
||||||
$shortUrls = $schema->getTable('short_urls');
|
$shortUrls = $schema->getTable('short_urls');
|
||||||
|
if ($shortUrls->hasColumn('max_visits')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$shortUrls->addColumn('max_visits', Type::INTEGER, [
|
$shortUrls->addColumn('max_visits', Type::INTEGER, [
|
||||||
'unsigned' => true,
|
'unsigned' => true,
|
||||||
'notnull' => false,
|
'notnull' => false,
|
||||||
@ -33,6 +37,10 @@ class Version20171022064541 extends AbstractMigration
|
|||||||
public function down(Schema $schema)
|
public function down(Schema $schema)
|
||||||
{
|
{
|
||||||
$shortUrls = $schema->getTable('short_urls');
|
$shortUrls = $schema->getTable('short_urls');
|
||||||
|
if (! $shortUrls->hasColumn('max_visits')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$shortUrls->dropColumn('max_visits');
|
$shortUrls->dropColumn('max_visits');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user