Skip to content

Commit

Permalink
Merge pull request #505 from dasgarner/develop
Browse files Browse the repository at this point in the history
Fix migrations for upgrading 1.8 to 2.0
  • Loading branch information
dasgarner authored Mar 6, 2019
2 parents 9827635 + 1e9df55 commit 26a9fb3
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ public function change()
}

$table = $this->table('user');
$table
->addColumn('isPasswordChangeRequired', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->save();
if (!$table->hasColumn('isPasswordChangeRequired')) {
$table
->addColumn('isPasswordChangeRequired', 'integer',
['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->save();
}
}
}
30 changes: 16 additions & 14 deletions db/migrations/20180906131716_data_set_rss_migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,21 @@ class DataSetRssMigration extends AbstractMigration
/** @inheritdoc */
public function change()
{
$table = $this->table('datasetrss');
$table
->addColumn('dataSetId', 'integer')
->addColumn('psk', 'string', ['limit' => 254])
->addColumn('title', 'string', ['limit' => 254])
->addColumn('author', 'string', ['limit' => 254])
->addColumn('titleColumnId', 'integer', ['null' => true, 'default' => null])
->addColumn('summaryColumnId', 'integer', ['null' => true, 'default' => null])
->addColumn('contentColumnId', 'integer', ['null' => true, 'default' => null])
->addColumn('publishedDateColumnId', 'integer', ['null' => true, 'default' => null])
->addColumn('sort', 'text', ['null' => true, 'default' => null])
->addColumn('filter', 'text', ['null' => true, 'default' => null])
->addForeignKey('dataSetId', 'dataset', 'dataSetId')
->save();
if (!$this->hasTable('datasetrss')) {
$table = $this->table('datasetrss');
$table
->addColumn('dataSetId', 'integer')
->addColumn('psk', 'string', ['limit' => 254])
->addColumn('title', 'string', ['limit' => 254])
->addColumn('author', 'string', ['limit' => 254])
->addColumn('titleColumnId', 'integer', ['null' => true, 'default' => null])
->addColumn('summaryColumnId', 'integer', ['null' => true, 'default' => null])
->addColumn('contentColumnId', 'integer', ['null' => true, 'default' => null])
->addColumn('publishedDateColumnId', 'integer', ['null' => true, 'default' => null])
->addColumn('sort', 'text', ['null' => true, 'default' => null])
->addColumn('filter', 'text', ['null' => true, 'default' => null])
->addForeignKey('dataSetId', 'dataset', 'dataSetId')
->save();
}
}
}
22 changes: 13 additions & 9 deletions db/migrations/20181126113231_release1812_migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ class Release1812Migration extends AbstractMigration
public function change()
{
// Add a setting allowing users to auto authorise new displays
$this->table('setting')->insert([
[
'setting' => 'DISPLAY_AUTO_AUTH',
'value' => 0,
'userSee' => 0,
'userChange' => 0
]
])->save();
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'DISPLAY_AUTO_AUTH\'')) {
$this->table('setting')->insert([
[
'setting' => 'DISPLAY_AUTO_AUTH',
'value' => 0,
'userSee' => 0,
'userChange' => 0
]
])->save();
}

// Rename Dashboard to Icon Dashboard
$this->execute('UPDATE `pages` set title = \'Icon Dashboard\', name = \'icondashboard\' WHERE `name` = \'dashboard\'');
Expand All @@ -48,6 +50,8 @@ public function change()
$this->execute('UPDATE `module` set Name = \'DataSet View\' WHERE `Module` = \'datasetview\'');

// Add M4V extension to Video module
$this->execute('UPDATE `module` SET validExtensions = CONCAT(validextensions, \',m4v\') WHERE `module` = \'video\' LIMIT 1;');
if (!$this->fetchRow('SELECT * FROM `module` WHERE `module` = \'video\' AND validExtensions LIKE \'%m4v%\'')) {
$this->execute('UPDATE `module` SET validExtensions = CONCAT(validextensions, \',m4v\') WHERE `module` = \'video\' LIMIT 1;');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class RemoveImageUriModuleMigration extends AbstractMigration
public function change()
{
$table = $this->table('module');
$table->removeColumn('imageUri')->update();
if ($table->hasColumn('imageUri')) {
$table->removeColumn('imageUri')->update();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ class CreatePlayerVersionsTableMigration extends AbstractMigration
/** @inheritdoc */
public function change()
{
$versions = $this->table('player_software', ['id' => 'versionId']);
$versions->addColumn('player_type', 'string', ['limit' => 20, 'default' => null, 'null' => true])
->addColumn('player_version', 'string', ['limit' => 15, 'default' => null, 'null' => true])
->addColumn('player_code', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_SMALL, 'null' => true])
->addColumn('mediaId', 'integer')
->addForeignKey('mediaId', 'media', 'mediaId')
->create();
if (!$this->hasTable('player_software')) {
$versions = $this->table('player_software', ['id' => 'versionId']);

$versions->addColumn('player_type', 'string', ['limit' => 20, 'default' => null, 'null' => true])
->addColumn('player_version', 'string', ['limit' => 15, 'default' => null, 'null' => true])
->addColumn('player_code', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_SMALL, 'null' => true])
->addColumn('mediaId', 'integer')
->addForeignKey('mediaId', 'media', 'mediaId')
->create();
}

// Add the player_software module
$modules = $this->table('module');
Expand Down
8 changes: 5 additions & 3 deletions db/migrations/20181217135044_event_sync_migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ public function change()
}

$scheduleTable = $this->table('schedule');
$syncColumn = $scheduleTable->hasColumn('syncEvent');

if (!$syncColumn)
$scheduleTable->addColumn('syncEvent', 'integer', ['default' => 0, 'null' => false])->save();
if (!$scheduleTable->hasColumn('syncEvent')) {
$scheduleTable
->addColumn('syncEvent', 'integer', ['default' => 0, 'null' => false])
->save();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,23 @@ public function change()
])->save();
}

$displayTableModified = false;

// remove version_instructions from display table
$versionInstructions = $displayTable->hasColumn('version_instructions');
if ($versionInstructions)
if ($displayTable->hasColumn('version_instructions')) {
$displayTable->removeColumn('version_instructions');
$displayTableModified = true;
}

// add overrideConfig column to display table
$overrideConfigColumn = $displayTable->hasColumn('overrideConfig');
if (!$overrideConfigColumn)
if (!$displayTable->hasColumn('overrideConfig')) {
$displayTable->addColumn('overrideConfig', 'text');
$displayTableModified = true;
}

$displayTable->save();
if ($displayTableModified) {
$displayTable->save();
}

// Get system user
$user = $this->fetchRow("SELECT userId FROM `user` WHERE userTypeId = 1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ class PlayerSoftwareVersionFieldMigration extends AbstractMigration
public function change()
{
$table = $this->table('player_software');
$table
->addColumn('playerShowVersion', 'string', ['limit' => 50])
->save();

if (!$table->hasColumn('playerShowVersion')) {
$table
->addColumn('playerShowVersion', 'string', ['limit' => 50])
->save();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<?php

/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

use Phinx\Migration\AbstractMigration;

/**
* Class MakeDisplayLicenseColumnUniqueMigration
*/
class MakeDisplayLicenseColumnUniqueMigration extends AbstractMigration
{
/** @inheritdoc */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<?php

/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

use Phinx\Migration\AbstractMigration;

/**
* Class AddDynamicCriteriaTagsMigration
*/
class AddDynamicCriteriaTagsMigration extends AbstractMigration
{
/** @inheritdoc */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<?php

/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

use Phinx\Migration\AbstractMigration;

/**
* Class AdjustGenericfileValidExtensionsMigration
*/
class AdjustGenericfileValidExtensionsMigration extends AbstractMigration
{
/** @inheritdoc */
Expand Down Expand Up @@ -33,6 +55,6 @@ public function change()
$newValidExtensions = implode(',', $newExtensions);

// update validExtensions for genericfile module with our adjusted extensions
$this->execute('UPDATE `module` SET `validExtensions` = ' . "'" . $newValidExtensions . "'" .' WHERE module = \'genericfile\' LIMIT 1;');
$this->execute('UPDATE `module` SET `validExtensions` = \'' . $newValidExtensions . '\' WHERE module = \'genericfile\' LIMIT 1;');
}
}

0 comments on commit 26a9fb3

Please sign in to comment.