Initial Upload

This commit is contained in:
Matt Batchelder
2025-12-02 10:32:59 -05:00
commit 05ce0da296
2240 changed files with 467811 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 OldUpgradeStep85Migration extends AbstractMigration
{
public function up()
{
$STEP = 85;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
$display = $this->table('display');
if (!$display->hasColumn('storageAvailableSpace')) {
$display
->addColumn('storageAvailableSpace', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'null' => true])
->addColumn('storageTotalSpace', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'null' => true])
->save();
}
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,65 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep86Migration extends AbstractMigration
{
public function up()
{
$STEP = 86;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$settings = $this->table('setting');
$settings
->insert([
[
'setting' => 'DASHBOARD_LATEST_NEWS_ENABLED',
'title' => 'Enable Latest News?',
'helptext' => 'Should the Dashboard show latest news? The address is provided by the theme.',
'value' => '1',
'fieldType' => 'checkbox',
'options' => '',
'cat' => 'general',
'userChange' => '1',
'type' => 'checkbox',
'validation' => '',
'ordering' => '110',
'default' => '1',
'userSee' => '1',
],
[
'setting' => 'LIBRARY_MEDIA_DELETEOLDVER_CHECKB',
'title' => 'Default for \"Delete old version of Media\" checkbox. Shown when Editing Library Media.',
'helptext' => 'Default the checkbox for Deleting Old Version of media when a new file is being uploaded to the library.',
'value' => 'Unchecked',
'fieldType' => 'dropdown',
'options' => 'Checked|Unchecked',
'cat' => 'defaults',
'userChange' => '1',
'type' => 'dropdown',
'validation' => '',
'ordering' => '50',
'default' => 'Unchecked',
'userSee' => '1',
]
])
->save();
// Update a setting
$this->execute('UPDATE `setting` SET `type` = \'checkbox\', `fieldType` = \'checkbox\' WHERE setting = \'SETTING_LIBRARY_TIDY_ENABLED\' OR setting = \'SETTING_IMPORT_ENABLED\';');
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep87Migration extends AbstractMigration
{
public function up()
{
$STEP = 87;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$settings = $this->table('setting');
$settings
->insert([
'setting' => 'PROXY_EXCEPTIONS',
'title' => 'Proxy Exceptions',
'helptext' => 'Hosts and Keywords that should not be loaded via the Proxy Specified. These should be comma separated.',
'value' => '1',
'fieldType' => 'text',
'options' => '',
'cat' => 'network',
'userChange' => '1',
'type' => 'string',
'validation' => '',
'ordering' => '32',
'default' => '',
'userSee' => '1',
])
->save();
// If we haven't run step85 during this migration, then we will want to update our storageAvailable columns
// Change to big ints.
$display = $this->table('display');
$display
->changeColumn('storageAvailableSpace', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'null' => true])
->changeColumn('storageTotalSpace', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'null' => true])
->save();
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep88Migration extends AbstractMigration
{
public function up()
{
$STEP = 88;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$auditLog = $this->table('auditlog', ['id' => 'logId']);
$auditLog->addColumn('logDate', 'integer')
->addColumn('userId', 'integer')
->addColumn('message', 'string', ['limit' => 255])
->addColumn('entity', 'string', ['limit' => 50])
->addColumn('entityId', 'integer')
->addColumn('objectAfter', 'text')
->save();
$this->execute('INSERT INTO `pages` (`name`, `pagegroupID`) SELECT \'auditlog\', pagegroupID FROM `pagegroup` WHERE pagegroup.pagegroup = \'Reports\';');
$group = $this->table('group');
if (!$group->hasColumn('libraryQuota')) {
$group->addColumn('libraryQuota', 'integer', ['null' => true])
->save();
}
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep92Migration extends AbstractMigration
{
public function up()
{
$STEP = 92;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$settings = $this->table('setting');
$settings
->insert([
'setting' => 'CDN_URL',
'title' => 'CDN Address',
'helptext' => 'Content Delivery Network Address for serving file requests to Players',
'value' => '',
'fieldType' => 'text',
'options' => '',
'cat' => 'network',
'userChange' => '0',
'type' => 'string',
'validation' => '',
'ordering' => '33',
'default' => '',
'userSee' => '0',
])
->save();
$this->execute('ALTER TABLE `datasetcolumn` CHANGE `ListContent` `ListContent` VARCHAR( 1000 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;');
$this->execute('ALTER TABLE `stat` ADD INDEX Type (`displayID`, `end`, `Type`);');
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,370 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 OldUpgradeStep120Migration extends AbstractMigration
{
public function up()
{
$STEP = 120;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$log = $this->table('log');
$log->removeColumn('scheduleId')
->removeColumn('layoutId')
->removeColumn('mediaId')
->removeColumn('requestUri')
->removeColumn('remoteAddr')
->removeColumn('userAgent')
->changeColumn('type', 'string', ['limit' => 254])
->addColumn('channel', 'string', ['limit' => 5, 'after' => 'logDate'])
->addColumn('runNo', 'string', ['limit' => 10])
->save();
$module = $this->table('module');
$module->addColumn('viewPath', 'string', ['limit' => 254, 'default' => '../modules'])
->addColumn('class', 'string', ['limit' => 254])
->save();
$permission = $this->table('permission', ['id' => 'permissionId']);
$permission->addColumn('entityId', 'integer')
->addColumn('groupId', 'integer')
->addColumn('objectId', 'integer')
->addColumn('view', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('edit', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('delete', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->save();
$permissionEntity = $this->table('permissionentity', ['id' => 'entityId']);
$permissionEntity->addColumn('entity', 'string', ['limit' => 50])
->addIndex('entity', ['unique' => true])
->insert([
['entity' => 'Xibo\\Entity\\Campaign'],
['entity' => 'Xibo\\Entity\\DataSet'],
['entity' => 'Xibo\\Entity\\DisplayGroup'],
['entity' => 'Xibo\\Entity\\Media'],
['entity' => 'Xibo\\Entity\\Page'],
['entity' => 'Xibo\\Entity\\Playlist'],
['entity' => 'Xibo\\Entity\\Region'],
['entity' => 'Xibo\\Entity\\Widget'],
])
->save();
$this->execute('INSERT INTO `permission` (`groupId`, `entityId`, `objectId`, `view`, `edit`, `delete`) SELECT groupId, 1, pageId, 1, 0, 0 FROM `lkpagegroup`;');
$this->execute('INSERT INTO `permission` (`groupId`, `entityId`, `objectId`, `view`, `edit`, `delete`) SELECT groupId, 5, campaignId, view, edit, del FROM `lkcampaigngroup`;');
$this->execute('INSERT INTO `permission` (`groupId`, `entityId`, `objectId`, `view`, `edit`, `delete`) SELECT groupId, 4, mediaId, view, edit, del FROM `lkmediagroup`;');
$this->execute('INSERT INTO `permission` (`groupId`, `entityId`, `objectId`, `view`, `edit`, `delete`) SELECT groupId, 9, dataSetId, view, edit, del FROM `lkdatasetgroup`;');
$this->execute('INSERT INTO `permission` (`groupId`, `entityId`, `objectId`, `view`, `edit`, `delete`) SELECT groupId, 3, displayGroupId, view, edit, del FROM `lkdisplaygroupgroup`;');
$this->table('lkpagegroup')->drop()->save();
$this->table('lkmenuitemgroup')->drop()->save();
$this->table('lkcampaigngroup')->drop()->save();
$this->table('lkmediagroup')->drop()->save();
$this->table('lkdatasetgroup')->drop()->save();
$this->table('lkdisplaygroupgroup')->drop()->save();
$pages = $this->table('pages');
$pages
->removeIndexByName('pages_ibfk_1')
->dropForeignKey('pageGroupId')
->removeColumn('pageGroupId')
->addColumn('title', 'string', ['limit' => 50])
->addColumn('asHome', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->insert([
['name' => 'region', 'title' => ''],
['name' => 'playlist', 'title' => ''],
['name' => 'maintenance', 'title' => ''],
])
->save();
$this->execute('INSERT INTO `permission` (`groupId`, `entityId`, `objectId`, `view`, `edit`, `delete`) SELECT `groupId`, 1, (SELECT pageId FROM `pages` WHERE `name` = \'region\'), `view`, `edit`, `delete` FROM `permission` WHERE `objectId` = (SELECT pageId FROM `pages` WHERE `name` = \'layout\') AND `entityId` = 1;');
$this->execute('INSERT INTO `permission` (`groupId`, `entityId`, `objectId`, `view`, `edit`, `delete`) SELECT `groupId`, 1, (SELECT pageId FROM `pages` WHERE `name` = \'playlist\'), `view`, `edit`, `delete` FROM `permission` WHERE `objectId` = (SELECT pageId FROM `pages` WHERE `name` = \'layout\') AND `entityId` = 1;');
$this->execute('UPDATE `pages` SET title = CONCAT(UCASE(LEFT(name, 1)), SUBSTRING(name, 2)), asHome = 1;');
$this->execute('UPDATE `pages` SET `name` = \'audit\' WHERE `name` = \'auditlog\';');
$this->execute('UPDATE `pages` SET asHome = 0 WHERE `name` IN (\'update\',\'admin\',\'manual\',\'help\',\'clock\',\'preview\',\'region\',\'playlist\',\'maintenance\');');
$this->execute('UPDATE `pages` SET `name` = \'library\', `title` = \'Library\' WHERE `pages`.`name` = \'content\';');
$this->execute('UPDATE `pages` SET `name` = \'applications\', `title` = \'Applications\' WHERE `pages`.`name` = \'oauth\';');
$this->execute('UPDATE `pages` SET `title` = \'Media Dashboard\' WHERE `pages`.`name` = \'mediamanager\';');
$this->execute('UPDATE `pages` SET `title` = \'Status Dashboard\' WHERE `pages`.`name` = \'statusdashboard\';');
$this->execute('UPDATE `pages` SET `title` = \'Display Profiles\' WHERE `pages`.`name` = \'displayprofile\';');
$this->execute('UPDATE `pages` SET `title` = \'Display Groups\' WHERE `pages`.`name` = \'displaygroup\';');
$this->execute('UPDATE `pages` SET `title` = \'Home\' WHERE `pages`.`name` = \'index\';');
$this->execute('UPDATE `pages` SET `title` = \'Audit Trail\' WHERE `pages`.`name` = \'auditlog\';');
$this->table('menuitem')->drop()->save();
$this->table('menu')->drop()->save();
$this->table('pagegroup')->drop()->save();
$layout = $this->table('layout');
$layout->addColumn('width', 'decimal')
->addColumn('height', 'decimal')
->addColumn('backgroundColor', 'string', ['limit' => 25, 'null' => true])
->addColumn('backgroundzIndex', 'integer', ['default' => 1])
->addColumn('schemaVersion', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->changeColumn('xml', 'text', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::TEXT_LONG, 'null' => true])
->addColumn('statusMessage', 'text', ['null' => true])
->save();
$this->execute('UPDATE `user` SET homepage = IFNULL((SELECT pageId FROM `pages` WHERE pages.name = `user`.homepage LIMIT 1), 1);');
$this->execute('ALTER TABLE `user` CHANGE `homepage` `homePageId` INT NOT NULL DEFAULT \'1\' COMMENT \'The users homepage\';');
$this->execute('DELETE FROM module WHERE module = \'counter\';');
$linkRegionPlaylist = $this->table('lkregionplaylist', ['id' => false, 'primary_key' => 'regionId', 'playlistId', 'displayOrder']);
$linkRegionPlaylist->addColumn('regionId', 'integer')
->addColumn('playlistId', 'integer')
->addColumn('displayOrder', 'integer')
->save();
$linkWidgetMedia = $this->table('lkwidgetmedia', ['id' => false, 'primary_key' => ['widgetId', 'mediaId']]);
$linkWidgetMedia->addColumn('widgetId', 'integer')
->addColumn('mediaId', 'integer')
->save();
$playlist = $this->table('playlist', ['id' => 'playlistId']);
$playlist->addColumn('name', 'string', ['limit' => 254])
->addColumn('ownerId', 'integer')
->save();
$region = $this->table('region', ['id' => 'regionId']);
$region
->addColumn('layoutId', 'integer')
->addColumn('ownerId', 'integer')
->addColumn('name', 'string', ['limit' => 254, 'null' => true])
->addColumn('width', 'decimal')
->addColumn('height', 'decimal')
->addColumn('top', 'decimal')
->addColumn('left', 'decimal')
->addColumn('zIndex', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_SMALL])
->addColumn('duration', 'integer', ['default' => 0])
->save();
$regionOption = $this->table('regionoption', ['id' => false, 'primary_key' => ['regionId', 'option']]);
$regionOption->addColumn('regionId', 'integer')
->addColumn('option', 'string', ['limit' => 50])
->addColumn('value', 'text', ['null' => true])
->save();
$widget = $this->table('widget', ['id' => 'widgetId']);
$widget
->addColumn('playlistId', 'integer')
->addColumn('ownerId', 'integer')
->addColumn('type', 'string', ['limit' => 50])
->addColumn('duration', 'integer')
->addColumn('displayOrder', 'integer')
->addColumn('calculatedDuration', 'integer')
->addColumn('useDuration', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 1])
->addForeignKey('playlistId', 'playlist', 'playlistId')
->addForeignKey('ownerId', 'user', 'userId')
->save();
$widgetOption = $this->table('widgetoption', ['id' => false, 'primary_key' => ['widgetId', 'type', 'option']]);
$widgetOption->addColumn('widgetId', 'integer')
->addColumn('type', 'string', ['limit' => 50])
->addColumn('option', 'string', ['limit' => 254])
->addColumn('value', 'text', ['null' => true])
->addForeignKey('widgetId', 'widget', 'widgetId')
->save();
$this->table('oauth_log')->drop()->save();
$this->table('oauth_server_nonce')->drop()->save();
$this->table('oauth_server_token')->drop()->save();
$this->table('oauth_server_registry')->drop()->save();
// New oAuth tables
$oauthClients = $this->table('oauth_clients', ['id' => false, 'primary_key' => ['id']]);
$oauthClients
->addColumn('id', 'string', ['limit' => 254])
->addColumn('secret', 'string', ['limit' => 254])
->addColumn('name', 'string', ['limit' => 254])
->addColumn('userId', 'integer')
->addColumn('authCode', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('clientCredentials', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->save();
$oauthSessions = $this->table('oauth_sessions');
$oauthSessions
->addColumn('owner_type', 'string', ['limit' => 254])
->addColumn('owner_id', 'string', ['limit' => 254])
->addColumn('client_id', 'string', ['limit' => 254])
->addColumn('client_redirect_uri', 'string', ['limit' => 500, 'null' => true])
->addForeignKey('client_id', 'oauth_clients', 'id', ['delete' => 'CASCADE'])
->save();
$oauthScopes = $this->table('oauth_scopes', ['id' => false, 'primary_key' => ['id']]);
$oauthScopes
->addColumn('id', 'string', ['limit' => 254])
->addColumn('description', 'string', ['limit' => 1000])
->save();
$oauthAccessTokens = $this->table('oauth_access_tokens', ['id' => false, 'primary_key' => ['access_token']]);
$oauthAccessTokens
->addColumn('access_token', 'string', ['limit' => 254])
->addColumn('session_id', 'integer')
->addColumn('expire_time', 'integer')
->addForeignKey('session_id', 'oauth_sessions', 'id', ['delete' => 'CASCADE'])
->save();
$oauthAccessTokenScopes = $this->table('oauth_access_token_scopes');
$oauthAccessTokenScopes
->addColumn('access_token', 'string', ['limit' => 254])
->addColumn('scope', 'string', ['limit' => 254])
->addForeignKey('access_token', 'oauth_access_tokens', 'access_token', ['delete' => 'CASCADE'])
->addForeignKey('scope', 'oauth_scopes', 'id', ['delete' => 'CASCADE'])
->save();
$oauthAuthCodes = $this->table('oauth_auth_codes', ['id' => false, 'primary_key' => ['auth_code']]);
$oauthAuthCodes
->addColumn('auth_code', 'string', ['limit' => 254])
->addColumn('session_id', 'integer')
->addColumn('expire_time', 'integer')
->addColumn('client_redirect_uri', 'string', ['limit' => 500])
->addForeignKey('session_id', 'oauth_sessions', 'id', ['delete' => 'CASCADE'])
->save();
$oauthAuthCodeScopes = $this->table('oauth_auth_code_scopes');
$oauthAuthCodeScopes
->addColumn('auth_code', 'string', ['limit' => 254])
->addColumn('scope', 'string', ['limit' => 254])
->addForeignKey('auth_code', 'oauth_auth_codes', 'auth_code', ['delete' => 'CASCADE'])
->addForeignKey('scope', 'oauth_scopes', 'id', ['delete' => 'CASCADE'])
->save();
$oauthClientRedirects = $this->table('oauth_client_redirect_uris');
$oauthClientRedirects
->addColumn('client_id', 'string', ['limit' => 254])
->addColumn('redirect_uri', 'string', ['limit' => 500])
->save();
$oauthRefreshToeksn = $this->table('oauth_refresh_tokens', ['id' => false, 'primary_key' => ['refresh_token']]);
$oauthRefreshToeksn
->addColumn('refresh_token', 'string', ['limit' => 254])
->addColumn('expire_time', 'integer')
->addColumn('access_token', 'string', ['limit' => 254])
->addForeignKey('access_token', 'oauth_access_tokens', 'access_token', ['delete' => 'CASCADE'])
->save();
$oauthSessionsScopes = $this->table('oauth_session_scopes');
$oauthSessionsScopes
->addColumn('session_id', 'integer')
->addColumn('scope', 'string', ['limit' => 254])
->addForeignKey('session_id', 'oauth_sessions', 'id', ['delete' => 'CASCADE'])
->addForeignKey('scope', 'oauth_scopes', 'id', ['delete' => 'CASCADE'])
->save();
$this->table('file')->drop()->save();
$this->execute('TRUNCATE TABLE `xmdsnonce`;');
$this->execute('RENAME TABLE `xmdsnonce` TO `requiredfile`;');
$requiredFile = $this->table('requiredfile');
$requiredFile->addColumn('requestKey', 'string', ['limit' => 10])
->addColumn('bytesRequested', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG])
->addColumn('complete' , 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->save();
$this->execute('ALTER TABLE `requiredfile` CHANGE `nonceId` `rfId` BIGINT( 20 ) NOT NULL AUTO_INCREMENT;');
$this->execute('ALTER TABLE `requiredfile` CHANGE `regionId` `regionId` INT NULL;');
$this->execute('ALTER TABLE `requiredfile` DROP `fileId`;');
$display = $this->table('display');
$display
->removeColumn('MediaInventoryXml')
->save();
$this->execute('DELETE FROM `setting` WHERE setting = \'USE_INTL_DATEFORMAT\';');
$this->execute('UPDATE `setting` SET `options` = \'Emergency|Alert|Critical|Error|Warning|Notice|Info|Debug\', value = \'Error\' WHERE setting = \'audit\';');
$this->execute('UPDATE `setting` SET `options` = \'private|group|public\' WHERE `setting`.`setting` IN (\'MEDIA_DEFAULT\', \'LAYOUT_DEFAULT\');');
$this->execute('INSERT INTO `setting` (`settingid`, `setting`, `value`, `fieldType`, `helptext`, `options`, `cat`, `userChange`, `title`, `validation`, `ordering`, `default`, `userSee`, `type`) VALUES (NULL, \'INSTANCE_SUSPENDED\', \'0\', \'checkbox\', \'Is this instance suspended?\', NULL, \'general\', \'0\', \'Instance Suspended\', \'\', \'120\', \'0\', \'0\', \'checkbox\'),(NULL, \'INHERIT_PARENT_PERMISSIONS\', \'1\', \'checkbox\', \'Inherit permissions from Parent when adding a new item?\', NULL, \'permissions\', \'1\', \'Inherit permissions\', \'\', \'50\', \'1\', \'1\', \'checkbox\');');
$this->execute('INSERT INTO `datatype` (`DataTypeID`, `DataType`) VALUES (\'5\', \'Library Image\');');
$this->execute('UPDATE `datatype` SET `DataType` = \'External Image\' WHERE `datatype`.`DataTypeID` =4 AND `datatype`.`DataType` = \'Image\' LIMIT 1 ;');
$this->table('lkdatasetlayout')->drop()->save();
$this->execute('CREATE TABLE `temp_lkmediadisplaygroup` AS SELECT `mediaid` ,`displaygroupid` FROM `lkmediadisplaygroup` WHERE 1 GROUP BY `mediaid` ,`displaygroupid`;');
$this->execute('DROP TABLE `lkmediadisplaygroup`;');
$this->execute('RENAME TABLE `temp_lkmediadisplaygroup` TO `lkmediadisplaygroup`;');
$this->execute('ALTER TABLE `lkmediadisplaygroup` ADD UNIQUE (`mediaid` ,`displaygroupid`);');
$this->execute('ALTER TABLE `lkcampaignlayout` ADD UNIQUE (`CampaignID` ,`LayoutID` ,`DisplayOrder`);');
$linkScheduleDisplayGroup = $this->table('lkscheduledisplaygroup', ['id' => false, 'primary_key' => ['eventId', 'displayGroupId']]);
$linkScheduleDisplayGroup
->addColumn('eventId', 'integer')
->addColumn('displayGroupId', 'integer')
->save();
$this->execute('ALTER TABLE `schedule_detail` DROP FOREIGN KEY `schedule_detail_ibfk_8` ;');
$this->execute('ALTER TABLE `schedule_detail` DROP `DisplayGroupID`;');
// Get all events and their Associated display group id's
foreach ($this->fetchAll('SELECT eventId, displayGroupIds FROM `schedule`') as $event) {
// Ping open the displayGroupIds
$displayGroupIds = explode(',', $event['displayGroupIds']);
// Construct some SQL to add the link
$sql = 'INSERT INTO `lkscheduledisplaygroup` (eventId, displayGroupId) VALUES ';
foreach ($displayGroupIds as $id) {
$sql .= '(' . $event['eventId'] . ',' . $id . '),';
}
$sql = rtrim($sql, ',');
$this->execute($sql);
}
$this->execute('ALTER TABLE `schedule` DROP `DisplayGroupIDs`;');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Image\' WHERE module = \'Image\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Video\' WHERE module = \'Video\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Flash\' WHERE module = \'Flash\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\PowerPoint\' WHERE module = \'PowerPoint\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\WebPage\' WHERE module = \'Webpage\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Ticker\' WHERE module = \'Ticker\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Text\' WHERE module = \'Text\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Embedded\' WHERE module = \'Embedded\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\DataSetView\' WHERE module = \'datasetview\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\ShellCommand\' WHERE module = \'shellcommand\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\LocalVideo\' WHERE module = \'localvideo\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\GenericFile\' WHERE module = \'genericfile\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Clock\' WHERE module = \'Clock\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Font\' WHERE module = \'Font\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Twitter\' WHERE module = \'Twitter\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\ForecastIo\' WHERE module = \'forecastio\';');
$this->execute('UPDATE `module` SET `class` = \'\\\\Xibo\\\\Widget\\\\Finance\' WHERE module = \'Finance\';');
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,144 @@
<?php
/*
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 OldUpgradeStep121Migration extends AbstractMigration
{
public function up()
{
$STEP = 121;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$display = $this->table('display');
$display
->addColumn('xmrChannel', 'string', ['limit' => 254, 'null' => true])
->addColumn('xmrPubKey', 'text', ['null' => true])
->addColumn('lastCommandSuccess', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 2])
->save();
$settings = $this->table('setting');
$settings
->insert([
[
'setting' => 'XMR_ADDRESS',
'title' => 'XMR Private Address',
'helptext' => 'Please enter the private address for XMR.',
'value' => 'http:://localhost:8081',
'fieldType' => 'checkbox',
'options' => '',
'cat' => 'displays',
'userChange' => '1',
'type' => 'string',
'validation' => '',
'ordering' => '5',
'default' => 'http:://localhost:8081',
'userSee' => '1',
],
[
'setting' => 'XMR_PUB_ADDRESS',
'title' => 'XMR Public Address',
'helptext' => 'Please enter the public address for XMR.',
'value' => 'tcp:://localhost:5556',
'fieldType' => 'dropdown',
'options' => 'Checked|Unchecked',
'cat' => 'displays',
'userChange' => '1',
'type' => 'string',
'validation' => '',
'ordering' => '6',
'default' => 'tcp:://localhost:5556',
'userSee' => '1',
]
])
->save();
$linkLayoutDisplayGroup = $this->table('lklayoutdisplaygroup', ['comment' => 'Layout associations directly to Display Groups']);
$linkLayoutDisplayGroup->addColumn('layoutId', 'integer')
->addColumn('displayGroupId', 'integer')
->addIndex(['layoutId', 'displayGroupId'], ['unique' => true])
->save();
$pages = $this->table('pages');
$pages->insert([
'name' => 'command',
'title' => 'Commands',
'asHome' => 1
])->save();
$command = $this->table('command', ['id' => 'commandId']);
$command->addColumn('command', 'string', ['limit' => 254])
->addColumn('code', 'string', ['limit' => 50])
->addColumn('description', 'string', ['limit' => 1000, 'null' => true])
->addColumn('userId', 'integer')
->save();
$linkCommandDisplayProfile = $this->table('lkcommanddisplayprofile', ['id' => false, 'primary_key' => ['commandId', 'displayProfileId']]);
$linkCommandDisplayProfile->addColumn('commandId', 'integer')
->addColumn('displayProfileId', 'integer')
->addColumn('commandString', 'string', ['limit' => 1000])
->addColumn('validationString', 'string', ['limit' => 1000])
->save();
$schedule = $this->table('schedule');
$schedule->changeColumn('campaignId', 'integer', ['null' => true])
->addColumn('eventTypeId', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'after' => 'eventId', 'default' => 1])
->addColumn('commandId', 'integer', ['after' => 'campaignId'])
->changeColumn('toDt', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'null' => true])
->save();
$this->execute('UPDATE `schedule` SET `eventTypeId` = 1;');
$scheduleDetail = $this->table('schedule_detail');
$scheduleDetail->changeColumn('toDt', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'null' => true])
->save();
$media = $this->table('media');
$media->addColumn('released', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 1])
->addColumn('apiRef', 'string', ['limit' => 254, 'null' => true])
->save();
$user = $this->table('user');
$user->addColumn('firstName', 'string', ['limit' => 254, 'null' => true])
->addColumn('lastName', 'string', ['limit' => 254, 'null' => true])
->addColumn('phone', 'string', ['limit' => 254, 'null' => true])
->addColumn('ref1', 'string', ['limit' => 254, 'null' => true])
->addColumn('ref2', 'string', ['limit' => 254, 'null' => true])
->addColumn('ref3', 'string', ['limit' => 254, 'null' => true])
->addColumn('ref4', 'string', ['limit' => 254, 'null' => true])
->addColumn('ref5', 'string', ['limit' => 254, 'null' => true])
->save();
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,87 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep122Migration extends AbstractMigration
{
public function up()
{
$STEP = 122;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$sql = '
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = \'' . $_SERVER['MYSQL_DATABASE'] . '\'
AND ENGINE = \'MyISAM\'
';
foreach ($this->fetchAll($sql) as $table) {
$this->execute('ALTER TABLE `' . $table['TABLE_NAME'] . '` ENGINE=INNODB', []);
}
$auditLog = $this->table('auditlog');
$auditLog->changeColumn('userId', 'integer', ['null' => true])
->save();
$dataSet = $this->table('dataset');
$dataSet->addColumn('code', 'string', ['limit' => 50, 'null' => true])
->addColumn('isLookup', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->save();
$module = $this->table('module');
$module->addColumn('defaultDuration', 'integer')
->save();
$this->execute('UPDATE `module` SET defaultDuration = 10;');
$this->execute('UPDATE `module` SET defaultDuration = (SELECT MAX(value) FROM `setting` WHERE setting = \'jpg_length\') WHERE `module` = \'image\';');
$this->execute('UPDATE `module` SET defaultDuration = (SELECT MAX(value) FROM `setting` WHERE setting = \'swf_length\') WHERE `module` = \'flash\';');
$this->execute('UPDATE `module` SET defaultDuration = (SELECT MAX(value) FROM `setting` WHERE setting = \'ppt_length\') WHERE `module` = \'powerpoint\';');
$this->execute('UPDATE `module` SET defaultDuration = 0 WHERE `module` = \'video\';');
$this->execute('DELETE FROM `setting` WHERE setting IN (\'ppt_length\', \'jpg_length\', \'swf_length\');');
$this->execute('UPDATE `widget` SET `calculatedDuration` = `duration`;');
$userOption = $this->table('useroption', ['id' => false, 'primary_key' => ['userId', 'option']]);
$userOption->addColumn('userId', 'integer')
->addColumn('option', 'string', ['limit' => 50])
->addColumn('value', 'text')
->save();
$displayGroup = $this->table('displaygroup');
$displayGroup->addColumn('isDynamic', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('dynamicCriteria', 'string', ['null' => true, 'limit' => 2000])
->addColumn('userId', 'integer')
->save();
$this->execute('UPDATE `displaygroup` SET userId = (SELECT userId FROM `user` WHERE usertypeid = 1 LIMIT 1) WHERE userId = 0;');
$session = $this->table('session');
$session->removeColumn('lastPage')
->removeColumn('securityToken')
->save();
$linkDisplayGroup = $this->table('lkdgdg', ['id' => false, ['primary_key' => ['parentId', 'childId', 'depth']]]);
$linkDisplayGroup
->addColumn('parentId', 'integer')
->addColumn('childId', 'integer')
->addColumn('depth', 'integer')
->addIndex(['childId', 'parentId', 'depth'], ['unique' => true])
->save();
$this->execute('INSERT INTO `lkdgdg` (parentId, childId, depth) SELECT displayGroupId, displayGroupId, 0 FROM `displaygroup` WHERE `displayGroupID` NOT IN (SELECT `parentId` FROM `lkdgdg` WHERE depth = 0);');
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep123Migration extends AbstractMigration
{
public function up()
{
$STEP = 123;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$schedule = $this->table('schedule');
$schedule->addColumn('dayPartId', 'integer')
->changeColumn('fromDt', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'null' => true])
->save();
// The following was added in step 92, we need to check to see if we already have this
if (!$this->fetchRow('SELECT * FROM setting WHERE setting = \'CDN_URL\'')) {
$settings = $this->table('setting');
$settings
->insert([
'setting' => 'CDN_URL',
'title' => 'CDN Address',
'helptext' => 'Content Delivery Network Address for serving file requests to Players',
'value' => '',
'fieldType' => 'text',
'options' => '',
'cat' => 'network',
'userChange' => '0',
'type' => 'string',
'validation' => '',
'ordering' => '33',
'default' => '',
'userSee' => '0',
])
->save();
}
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,137 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep124Migration extends AbstractMigration
{
public function up()
{
$STEP = 124;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$group = $this->table('group');
$group->addColumn('isSystemNotification', 'integer', ['default' => 0])
->insert([
'group' => 'System Notifications',
'isUserSpecific' => 0,
'isSystemNotification' => 1
])
->save();
$notification = $this->table('notification', ['id' => 'notificationId']);
$notification
->addColumn('subject', 'string', ['limit' => 255])
->addColumn('body', 'text', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::TEXT_LONG])
->addColumn('createDt', 'integer')
->addColumn('releaseDt', 'integer')
->addColumn('isEmail', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('isInterrupt', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('isSystem', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('userId', 'integer')
->save();
$linkNotificationDg = $this->table('lknotificationdg', ['id' => 'lkNotificationDgId']);
$linkNotificationDg
->addColumn('notificationId', 'integer')
->addColumn('displayGroupId', 'integer')
->addIndex(['notificationId', 'displayGroupId'], ['unique' => true])
->save();
$linkNotificationGroup = $this->table('lknotificationgroup', ['id' => 'lkNotificationGroupId']);
$linkNotificationGroup
->addColumn('notificationId', 'integer')
->addColumn('groupId', 'integer')
->addIndex(['notificationId', 'groupId'], ['unique' => true])
->save();
$linkNotificationUser = $this->table('lknotificationuser', ['id' => 'lkNotificationUserId']);
$linkNotificationUser
->addColumn('notificationId', 'integer')
->addColumn('userId', 'integer')
->addColumn('read', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('readDt', 'integer')
->addColumn('emailDt', 'integer')
->addIndex(['notificationId', 'userId'], ['unique' => true])
->save();
$pages = $this->table('pages');
$pages->insert([
[
'name' => 'notification',
'title' => 'Notifications',
'asHome' => 0
],
[
'name' => 'drawer',
'title' => 'Notification Drawer',
'asHome' => 0
]
])->save();
$permissionEntity = $this->table('permissionentity');
$permissionEntity->insert([
'entity' => '\\Xibo\\Entity\\Notification'
])->save();
$this->execute('UPDATE `group` SET isSystemNotification = 1 WHERE isUserSpecific = 1 AND `groupId` IN (SELECT `groupId` FROM `lkusergroup` INNER JOIN `user` ON `user`.userId = `lkusergroup`.userId WHERE `user`.userTypeId = 1);');
// If we've run step 92 as part of this upgrade, then don't do the below
$this->execute('ALTER TABLE `datasetcolumn` CHANGE `ListContent` `ListContent` VARCHAR( 1000 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;');
if (!$this->checkIndexExists('stat', ['displayId', 'end', 'type'], false)) {
$this->execute('ALTER TABLE `stat` ADD INDEX Type (`displayID`, `end`, `Type`);');
}
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
/**
* Check if an index exists
* @param string $table
* @param string[] $columns
* @param bool $isUnique
* @return bool
* @throws InvalidArgumentException
*/
private function checkIndexExists($table, $columns, $isUnique)
{
if (!is_array($columns) || count($columns) <= 0)
throw new InvalidArgumentException('Incorrect call to checkIndexExists', 'columns');
// Use the information schema to see if the index exists or not.
// all users have permission to the information schema
$sql = '
SELECT *
FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_schema=DATABASE()
AND table_name = \'' . $table . '\'
AND non_unique = \'' . (($isUnique) ? 0 : 1) . '\'
AND (
';
$i = 0;
foreach ($columns as $column) {
$i++;
$sql .= (($i == 1) ? '' : ' OR') . ' (seq_in_index = \'' . $i . '\' AND column_name = \'' . $column . '\') ';
}
$sql .= ' )';
$indexes = $this->fetchAll($sql);
return (count($indexes) === count($columns));
}
}

View File

@@ -0,0 +1,77 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep125Migration extends AbstractMigration
{
public function up()
{
$STEP = 125;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$schedule = $this->table('schedule');
$schedule->changeColumn('is_priority', 'integer')
->save();
$this->execute('
INSERT INTO module (Module, Name, Enabled, RegionSpecific, Description, ImageUri, SchemaVersion, ValidExtensions, PreviewEnabled, assignable, render_as, settings, viewPath, class, defaultDuration) VALUES
(\'audio\', \'Audio\', 1, 0, \'Audio - support varies depending on the client hardware\', \'forms/video.gif\', 1, \'mp3,wav\', 1, 1, null, null, \'../modules\', \'Xibo\\\\Widget\\\\Audio\', 0),
(\'pdf\', \'PDF\', 1, 0, \'PDF document viewer\', \'forms/pdf.gif\', 1, \'pdf\', 1, 1, \'html\', null, \'../modules\', \'Xibo\\\\Widget\\\\Pdf\', 60);
');
$linkWidgetAudio = $this->table('lkwidgetaudio', ['id' => false, 'primary_key' => ['widgetId', 'mediaId']]);
$linkWidgetAudio->addColumn('widgetId', 'integer')
->addColumn('mediaId', 'integer')
->addColumn('volume', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('loop', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->save();
$oauthClientScopes = $this->table('oauth_client_scopes');
$oauthClientScopes
->addColumn('clientId', 'string', ['limit' => 254])
->addColumn('scopeId', 'string', ['limit' => 254])
->addIndex(['clientId', 'scopeId'], ['unique' => true])
->save();
// Bulk insert doesn't appear to handle non auto-index primary keys?!
$this->execute('
INSERT INTO `oauth_scopes` (id, description) VALUES
(\'all\', \'All access\'),
(\'mcaas\', \'Media Conversion as a Service\')
');
$oauthRouteScopes = $this->table('oauth_scope_routes');
$oauthRouteScopes
->addColumn('scopeId', 'string', ['limit' => 254])
->addColumn('route', 'string', ['limit' => 1000])
->addColumn('method', 'string', ['limit' => 8])
->insert([
['scopeId' => 'mcaas', 'route' => '/', 'method' => 'GET'],
['scopeId' => 'mcaas', 'route' => '/library/download/:id(/:type)', 'method' => 'GET'],
['scopeId' => 'mcaas', 'route' => '/library/mcaas/:id', 'method' => 'POST'],
])
->save();
$module = $this->table('module');
$module->addColumn('installName', 'string', ['limit' => 254, 'null' => true])
->save();
$this->execute('ALTER TABLE display CHANGE isAuditing auditingUntil int NOT NULL DEFAULT \'0\' COMMENT \'Is this display auditing\';');
$this->execute('INSERT INTO setting (setting, value, fieldType, helptext, options, cat, userChange, title, validation, ordering, `default`, userSee, type) VALUES (\'ELEVATE_LOG_UNTIL\', \'1463396415\', \'datetime\', \'Elevate the log level until this date.\', null, \'troubleshooting\', 1, \'Elevate Log Until\', \' \', 25, \'\', 1, \'datetime\');');
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,44 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep126Migration extends AbstractMigration
{
public function up()
{
$STEP = 126;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$stat = $this->table('stat');
$stat->addColumn('widgetId', 'integer', ['null' => true])
->save();
$displayEvent = $this->table('displayevent', ['id' => 'displayEventId']);
$displayEvent
->addColumn('eventDate', 'integer')
->addColumn('displayId', 'integer')
->addColumn('start', 'integer')
->addColumn('end', 'integer', ['null' => true])
->addIndex('eventDate')
->addIndex('end')
->save();
$this->execute('INSERT INTO displayevent (eventDate, displayId, start, end) SELECT UNIX_TIMESTAMP(statDate), displayID, UNIX_TIMESTAMP(start), UNIX_TIMESTAMP(end) FROM stat WHERE Type = \'displaydown\';');
$this->execute('DELETE FROM stat WHERE Type = \'displaydown\';');
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,126 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep127Migration extends AbstractMigration
{
public function up()
{
$STEP = 127;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$schedule = $this->table('schedule');
$schedule->addColumn('recurrenceRepeatsOn', 'string', ['null' => true])
->save();
$this->execute('INSERT INTO `setting` (`setting`, `value`, `fieldType`, `helptext`, `options`, `cat`, `userChange`, `title`, `validation`, `ordering`, `default`, `userSee`, `type`) VALUES (\'RESTING_LOG_LEVEL\', \'Error\', \'dropdown\', \'Set the level of the resting log level. The CMS will revert to this log level after an elevated period ends. In production systems \"error\" is recommended.\', \'Emergency|Alert|Critical|Error\', \'troubleshooting\', 1, \'Resting Log Level\', \'\', 19, \'error\', 1, \'word\');');
$dataSet = $this->table('dataset');
$dataSet->changeColumn('code', 'string', ['limit' => 50, 'null' => true])
->save();
$this->execute('INSERT INTO `pages` (`name`, `Title`, `asHome`) VALUES (\'daypart\', \'Dayparting\', 0);');
$dayPart = $this->table('daypart', ['id' => 'dayPartId']);
$dayPart
->addColumn('name', 'string', ['limit' => 50])
->addColumn('description', 'string', ['limit' => 50, 'null' => true])
->addColumn('isRetired', 'integer', ['default' => 0, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('userId', 'integer')
->addColumn('startTime', 'string', ['limit' => 8, 'default' => '00:00:00'])
->addColumn('endTime', 'string', ['limit' => 8, 'default' => '00:00:00'])
->addColumn('exceptions', 'text')
->save();
$this->execute('INSERT INTO `permissionentity` (`entityId`, `entity`) VALUES (NULL, \'Xibo\\Entity\\DayPart\');');
$user = $this->table('user');
$user->changeColumn('userPassword', 'string', ['limit' => 255]);
$this->execute('INSERT INTO pages (name, title, asHome) VALUES (\'task\', \'Task\', 1);');
$this->execute('INSERT INTO setting (setting, value, fieldType, helptext, options, cat, userChange, title, validation, ordering, `default`, userSee, type) VALUES (\'TASK_CONFIG_LOCKED_CHECKB\', \'Unchecked\', \'dropdown\', \'Is the task config locked? Useful for Service providers.\', \'Checked|Unchecked\', \'defaults\', 0, \'Lock Task Config\', \'\', 30, \'Unchecked\', 0, \'word\');');
$task = $this->table('task', ['id' => 'taskId']);
$task
->addColumn('name', 'string', ['limit' => 254])
->addColumn('class', 'string', ['limit' => 254])
->addColumn('status', 'integer', ['default' => 2, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('pid', 'integer')
->addColumn('options', 'text')
->addColumn('schedule', 'string', ['limit' => 254])
->addColumn('lastRunDt', 'integer')
->addColumn('lastRunMessage', 'string', ['null' => true])
->addColumn('lastRunStatus', 'integer', ['default' => 0, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('lastRunDuration', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_SMALL])
->addColumn('lastRunExitCode', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_SMALL])
->addColumn('isActive', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('runNow', 'integer', ['default' => 0, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('configFile', 'string', ['limit' => 254])
->insert([
[
'name' => 'Daily Maintenance',
'class' => '\Xibo\XTR\MaintenanceDailyTask',
'options' => '[]',
'schedule' => '0 0 * * * *',
'isActive' => '1',
'configFile' => '/tasks/maintenance-daily.task'
],
[
'name' => 'Regular Maintenance',
'class' => '\Xibo\XTR\MaintenanceRegularTask',
'options' => '[]',
'schedule' => '*/5 * * * * *',
'isActive' => '1',
'configFile' => '/tasks/maintenance-regular.task'
],
[
'name' => 'Email Notifications',
'class' => '\Xibo\XTR\EmailNotificationsTask',
'options' => '[]',
'schedule' => '*/5 * * * * *',
'isActive' => '1',
'configFile' => '/tasks/email-notifications.task'
],
[
'name' => 'Stats Archive',
'class' => '\Xibo\XTR\StatsArchiveTask',
'options' => '{"periodSizeInDays":"7","maxPeriods":"4"}',
'schedule' => '0 0 * * Mon',
'isActive' => '1',
'configFile' => '/tasks/stats-archiver.task'
],
[
'name' => 'Remove old Notifications',
'class' => '\Xibo\XTR\NotificationTidyTask',
'options' => '{"maxAgeDays":"7","systemOnly":"1","readOnly":"0"}',
'schedule' => '15 0 * * *',
'isActive' => '1',
'configFile' => '/tasks/notification-tidy.task'
]
])
->save();
$this->execute('INSERT INTO `setting` (setting, value, fieldType, helptext, options, cat, userChange, title, validation, ordering, `default`, userSee, type) VALUES(\'WHITELIST_LOAD_BALANCERS\', \'\', \'text\', \'If the CMS is behind a load balancer, what are the load balancer IP addresses, comma delimited.\', \'\', \'network\', 1, \'Whitelist Load Balancers\', \'\', 100, \'\', 1, \'string\');');
$this->execute('INSERT INTO `setting` (setting, value, fieldType, helptext, options, cat, userChange, title, validation, ordering, `default`, userSee, type) VALUES(\'DEFAULT_LAYOUT\', \'1\', \'text\', \'The default layout to assign for new displays and displays which have their current default deleted.\', \'1\', \'displays\', 1, \'Default Layout\', \'\', 4, \'\', 1, \'int\');');
$display = $this->table('display');
$display->addColumn('deviceName', 'string', ['null' => true])
->save();
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,128 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 OldUpgradeStep128Migration extends AbstractMigration
{
public function up()
{
$STEP = 128;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$this->execute('UPDATE `resolution` SET resolution = \'4k cinema\' WHERE resolution = \'4k\';');
$this->execute('INSERT INTO `resolution` (`resolution`, `width`, `height`, `intended_width`, `intended_height`, `version`, `enabled`) VALUES(\'4k UHD Landscape\', 450, 800, 3840, 2160, 2, 1),(\'4k UHD Portrait\', 800, 450, 2160, 3840, 2, 1);');
$this->execute('UPDATE schedule SET fromDt = 0, toDt = 2556057600 WHERE dayPartId = 1');
$this->table('schedule_detail')->drop()->save();
$schedule = $this->table('schedule');
$schedule->addColumn('lastRecurrenceWatermark', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'null' => true])
->save();
$this->table('requiredfile')->drop()->save();
$log = $this->table('log');
$log
->changeColumn('channel', 'string', ['limit' => 20])
->save();
$this->execute('UPDATE `setting` SET `helpText` = \'The Time to Live (maxage) of the STS header expressed in seconds.\' WHERE `setting` = \'STS_TTL\';');
if (!$this->checkIndexExists('lkdisplaydg', ['displayGroupId', 'displayId'], 1)) {
$index = 'CREATE UNIQUE INDEX lkdisplaydg_displayGroupId_displayId_uindex ON `lkdisplaydg` (displayGroupId, displayId);';
// Try to create the index, if we fail, assume duplicates
try {
$this->execute($index);
} catch (\PDOException $e) {
// Create a verify table
$this->execute('CREATE TABLE lkdisplaydg_verify AS SELECT * FROM lkdisplaydg WHERE 1 GROUP BY displaygroupId, displayId;');
// Delete from original table
$this->execute('DELETE FROM lkdisplaydg;');
// Insert the de-duped records
$this->execute('INSERT INTO lkdisplaydg SELECT * FROM lkdisplaydg_verify;');
// Drop the verify table
$this->execute('DROP TABLE lkdisplaydg_verify;');
// Create the index fresh, now that duplicates removed
$this->execute($index);
}
}
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
/**
* Check if an index exists
* @param string $table
* @param string[] $columns
* @param bool $isUnique
* @return bool
* @throws InvalidArgumentException
*/
private function checkIndexExists($table, $columns, $isUnique)
{
if (!is_array($columns) || count($columns) <= 0)
throw new InvalidArgumentException('Incorrect call to checkIndexExists', 'columns');
// Use the information schema to see if the index exists or not.
// all users have permission to the information schema
$sql = '
SELECT *
FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_schema=DATABASE()
AND table_name = \'' . $table . '\'
AND non_unique = \'' . (($isUnique) ? 0 : 1) . '\'
AND (
';
$i = 0;
foreach ($columns as $column) {
$i++;
$sql .= (($i == 1) ? '' : ' OR') . ' (seq_in_index = \'' . $i . '\' AND column_name = \'' . $column . '\') ';
}
$sql .= ' )';
$indexes = $this->fetchAll($sql);
return (count($indexes) === count($columns));
}
}

View File

@@ -0,0 +1,60 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep129Migration extends AbstractMigration
{
public function up()
{
$STEP = 129;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$requiredFile = $this->table('requiredfile', ['id' => 'rfId']);
$requiredFile
->addColumn('displayId', 'integer')
->addColumn('type', 'string', ['limit' => 1])
->addColumn('class', 'string', ['limit' => 1])
->addColumn('itemId', 'integer', ['null' => true])
->addColumn('bytesRequested', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG])
->addColumn('complete', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('path', 'string', ['null' => true, 'limit' => 255])
->addColumn('size', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG, 'default' => 0])
->addIndex(['displayId', 'type'])
->save();
$resolution = $this->table('resolution');
$resolution
->addColumn('userId', 'integer')
->save();
$this->execute('UPDATE `resolution` SET userId = 0;');
$this->execute('UPDATE `setting` SET `options` = \'private|group|group write|public|public write\' WHERE setting IN (\'MEDIA_DEFAULT\', \'LAYOUT_DEFAULT\');');
$linkCampaignTag = $this->table('lktagcampaign', ['id' => 'lkTagCampaignId']);
$linkCampaignTag
->addColumn('tagId', 'integer')
->addColumn('campaignId', 'integer')
->addIndex(['tagId', 'campaignId'], ['unique' => true])
->save();
$display = $this->table('display');
$display
->addColumn('timeZone', 'string', ['limit' => 254, 'null' => true])
->save();
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep130Migration extends AbstractMigration
{
public function up()
{
$STEP = 130;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$schedule = $this->table('schedule');
$schedule
->addColumn('syncTimezone', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->save();
$this->execute('UPDATE `permissionentity` SET entity = \'Xibo\\Entity\\Notification\' WHERE entity = \'XiboEntityNotification\';');
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'oauth_clients%\' AND referenced_table_name = \'user\';')) {
$this->execute('UPDATE `oauth_clients` SET userId = (SELECT userId FROM `user` WHERE userTypeId = 1 LIMIT 1)
WHERE userId NOT IN (SELECT userId FROM `user`);');
$this->execute('ALTER TABLE `oauth_clients` ADD CONSTRAINT oauth_clients_user_UserID_fk FOREIGN KEY (userId) REFERENCES `user` (UserID);');
}
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 OldUpgradeStep131Migration extends AbstractMigration
{
public function up()
{
$STEP = 131;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$this->execute('INSERT INTO `setting` (`setting`, `value`, `fieldType`, `helptext`, `options`, `cat`, `userChange`, `title`, `validation`, `ordering`, `default`, `userSee`, `type`) VALUES (\'DISPLAY_PROFILE_STATS_DEFAULT\', \'0\', \'checkbox\', NULL, NULL, \'displays\', 1, \'Default setting for Statistics Enabled?\', \'\', 70, \'0\', 1, \'checkbox\'),(\'DISPLAY_PROFILE_CURRENT_LAYOUT_STATUS_ENABLED\', \'1\', \'checkbox\', NULL, NULL, \'displays\', 1, \'Enable the option to report the current layout status?\', \'\', 80, \'0\', 1, \'checkbox\'),(\'DISPLAY_PROFILE_SCREENSHOT_INTERVAL_ENABLED\', \'1\', \'checkbox\', NULL, NULL, \'displays\', 1, \'Enable the option to set the screenshot interval?\', \'\', 90, \'0\', 1, \'checkbox\'),(\'DISPLAY_PROFILE_SCREENSHOT_SIZE_DEFAULT\', \'200\', \'number\', \'The default size in pixels for the Display Screenshots\', NULL, \'displays\', 1, \'Display Screenshot Default Size\', \'\', 100, \'200\', 1, \'int\'),(\'LATEST_NEWS_URL\', \'https://xibosignage.com/feed\', \'text\', \'RSS/Atom Feed to be displayed on the Status Dashboard\', \'\', \'general\', 0, \'Latest News URL\', \'\', 111, \'\', 0, \'string\');');
$display = $this->table('display');
$display->removeColumn('currentLayoutId')->save();
$permissionEntity = $this->table('permissionentity');
$permissionEntity->insert([
'entity' => 'Xibo\\Entity\\Display'
])->save();
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep132Migration extends AbstractMigration
{
public function up()
{
$STEP = 132;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$this->execute('UPDATE `schedule` SET toDt = 2147483647 WHERE toDt = 2556057600;');
$this->execute('UPDATE `permission` SET
entityId = (
SELECT entityId
FROM permissionentity
WHERE entity = \'Xibo\\Entity\\DisplayGroup\'),
objectId = (
SELECT lkdisplaydg.DisplayGroupID
FROM `lkdisplaydg`
INNER JOIN `displaygroup` ON `displaygroup`.DisplayGroupID = `lkdisplaydg`.DisplayGroupID
AND `displaygroup`.IsDisplaySpecific = 1
WHERE permission.objectId = `lkdisplaydg`.DisplayID)
WHERE entityId IN (SELECT entityId FROM permissionentity WHERE entity = \'Xibo\\Entity\\Display\');');
$this->execute('DELETE FROM `permissionentity` WHERE `entity` = \'Xibo\\Entity\\Display\';');
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep133Migration extends AbstractMigration
{
public function up()
{
$STEP = 133;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$this->execute('INSERT INTO `setting` (`setting`, `value`, `fieldType`, `helptext`, `options`, `cat`, `userChange`, `title`, `validation`, `ordering`, `default`, `userSee`, `type`) VALUES (\'DISPLAY_LOCK_NAME_TO_DEVICENAME\', \'0\', \'checkbox\', NULL, NULL, \'displays\', 1, \'Lock the Display Name to the device name provided by the Player?\', \'\', 80, \'0\', 1, \'checkbox\');');
$task = $this->table('task');
$task
->addColumn('lastRunStartDt', 'integer', ['null' => true])
->save();
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
use Phinx\Migration\AbstractMigration;
class OldUpgradeStep134Migration extends AbstractMigration
{
public function up()
{
$STEP = 134;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$this->execute('INSERT INTO displayprofile (name, type, config, isdefault, userId) VALUES (\'webOS\', \'lg\', \'{}\', 1, 1)');
$this->execute('INSERT INTO module (Module, Name, Enabled, RegionSpecific, Description, ImageUri, SchemaVersion, ValidExtensions, PreviewEnabled, assignable, render_as, settings, viewPath, class, defaultDuration) VALUES (\'notificationview\', \'Notification\', 1, 1, \'Display Notifications from the Notification Centre\', \'forms/library.gif\', 1, null, 1, 1, \'html\', null, \'../modules\', \'Xibo\\\\Widget\\\\NotificationView\', 10);');
$group = $this->table('group');
$group
->addColumn('isDisplayNotification', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->save();
$this->execute('DELETE FROM `setting` WHERE setting = \'MAINTENANCE_ALERTS_FOR_VIEW_USERS\';');
$linkTagDisplayGroup = $this->table('lktagdisplaygroup', ['id' => 'lkTagDisplayGroupId']);
$linkTagDisplayGroup
->addColumn('tagId', 'integer')
->addColumn('displayGroupId', 'integer')
->addIndex(['tagId', 'displayGroupId'], ['unique' => true])
->save();
$media = $this->table('media');
$media
->addColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->save();
$this->execute('UPDATE `module` SET validextensions = CONCAT(validextensions, \',ipk\') WHERE module = \'genericfile\' LIMIT 1;');
$this->execute('UPDATE `module` SET description = \'A module for showing Currency pairs and exchange rates\' WHERE module = \'currencies\';');
$this->execute('UPDATE `module` SET description = \'A module for showing Stock quotes\' WHERE module = \'stocks\';');
// Bump our version
$this->execute('UPDATE `version` SET DBVersion = ' . $STEP);
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 OldUpgradeStep135Migration extends AbstractMigration
{
public function up()
{
$STEP = 135;
// Are we an upgrade from an older version?
if ($this->hasTable('version')) {
// We do have a version table, so we're an upgrade from anything 1.7.0 onward.
$row = $this->fetchRow('SELECT * FROM `version`');
$dbVersion = $row['DBVersion'];
// Are we on the relevent step for this upgrade?
if ($dbVersion < $STEP) {
// Perform the upgrade
$dataSet = $this->table('dataset');
$dataSet
->addColumn('isRemote', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('method', 'enum', ['values' => ['GET', 'POST'], 'null' => true])
->addColumn('uri', 'string', ['limit' => 250, 'null' => true])
->addColumn('postData', 'text', ['null' => true])
->addColumn('authentication', 'enum', ['values' => ['none', 'plain', 'basic', 'digest'], 'null' => true])
->addColumn('username', 'string', ['limit' => 250, 'null' => true])
->addColumn('password', 'string', ['limit' => 250, 'null' => true])
->addColumn('refreshRate', 'integer', ['default' => 86400])
->addColumn('clearRate', 'integer', ['default' => 0])
->addColumn('runsAfter', 'integer', ['default' => null, 'null' => true])
->addColumn('dataRoot', 'string', ['limit' => 250, 'null' => true])
->addColumn('lastSync', 'integer', ['default' => 0])
->addColumn('summarize', 'string', ['limit' => 10, 'null' => true])
->addColumn('summarizeField', 'string', ['limit' => 250, 'null' => true])
->save();
$dataSetColumn = $this->table('datasetcolumn');
$dataSetColumn
->addColumn('remoteField', 'string', ['limit' => 250, 'null' => true, 'after' => 'formula'])
->save();
$task = $this->table('task');
$task->insert([
[
'name' => 'Fetch Remote DataSets',
'class' => '\Xibo\XTR\RemoteDataSetFetchTask',
'options' => '[]',
'schedule' => '30 * * * * *',
'isActive' => '1',
'configFile' => '/tasks/remote-dataset.task'
],
[
'name' => 'Update Empty Video Durations',
'class' => '\Xibo\XTR\UpdateEmptyVideoDurations',
'options' => '[]',
'schedule' => '0 0 1 1 *',
'isActive' => '1',
'configFile' => '/tasks/update-empty-video-durations.task',
'runNow' => 1
],
[
'name' => 'Drop Player Cache',
'class' => '\Xibo\XTR\DropPlayerCacheTask',
'options' => '[]',
'schedule' => '0 0 1 1 *',
'isActive' => '1',
'configFile' => '/tasks/drop-player-cache.task',
'runNow' => 1
],
[
'name' => 'DataSet Convert (only run once)',
'class' => '\Xibo\XTR\DataSetConvertTask',
'options' => '[]',
'schedule' => '0 0 1 1 *',
'isActive' => '1',
'configFile' => '/tasks/dataset-convert.task',
'runNow' => 1
],
[
'name' => 'Layout Convert (only run once)',
'class' => '\Xibo\XTR\LayoutConvertTask',
'options' => '[]',
'schedule' => '0 0 1 1 *',
'isActive' => '1',
'configFile' => '/tasks/layout-convert.task',
'runNow' => 1
],
])->save();
// If we've run the old upgrader, remove it
if ($this->hasTable('upgrade'))
$this->table('upgrade')->drop()->save();
// Remove the version table
$this->table('version')->drop()->save();
}
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
/*
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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;
/**
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
* @phpcs:disable Generic.Files.LineLength.TooLong
*/
class OneRegionPerPlaylistMigration extends AbstractMigration
{
/**
* Up
*/
public function up()
{
$playlist = $this->table('playlist');
$playlist
->addColumn('regionId', 'integer', ['null' => true])
->addColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('duration', 'integer', ['default' => 0])
->addColumn(
'requiresDurationUpdate',
'integer',
['default' => 0, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]
)
->addIndex('regionId')
->save();
$this->execute('UPDATE `playlist` SET regionId = (SELECT MAX(regionId) FROM lkregionplaylist WHERE playlist.playlistId = lkregionplaylist.playlistId);');
$this->table('lkregionplaylist')->drop()->save();
$this->execute('UPDATE `pages` SET asHome = 1 WHERE name = \'playlist\';');
$this->execute('
INSERT INTO module (Module, Name, Enabled, RegionSpecific, Description, ImageUri, SchemaVersion, ValidExtensions, PreviewEnabled, assignable, render_as, settings, viewPath, class, defaultDuration)
VALUES (\'subplaylist\', \'Sub-Playlist\', 1, 1, \'Embed a Sub-Playlist\', \'forms/library.gif\', 1, null, 1, 1, \'native\', null, \'../modules\', \'Xibo\\\\Widget\\\\SubPlaylist\', 10);
');
$playlistClosure = $this->table('lkplaylistplaylist', ['id' => false, 'primary_key' => ['parentId', 'childId', 'depth']]);
$playlistClosure
->addColumn('parentId', 'integer')
->addColumn('childId', 'integer')
->addColumn('depth', 'integer')
->addIndex(['childId', 'parentId', 'depth'], ['unique' => true])
->save();
$this->execute('INSERT INTO lkplaylistplaylist (parentId, childId, depth) SELECT playlistId, playlistId, 0 FROM playlist;');
}
}

View File

@@ -0,0 +1,20 @@
<?php
use Phinx\Migration\AbstractMigration;
class PlaylistTagsMigration extends AbstractMigration
{
/**
* Change Method.
*/
public function change()
{
$linkPlaylistTag = $this->table('lktagplaylist', ['id' => 'lkTagPlaylistId']);
$linkPlaylistTag
->addColumn('tagId', 'integer')
->addColumn('playlistId', 'integer')
->addIndex(['tagId', 'playlistId'], ['unique' => true])
->save();
}
}

View File

@@ -0,0 +1,21 @@
<?php
use Phinx\Migration\AbstractMigration;
class WidgetFromToDtMigration extends AbstractMigration
{
/**
* Change Method.
*/
public function change()
{
$widget = $this->table('widget');
$widget
->addColumn('fromDt', 'integer')
->addColumn('toDt', 'integer')
->save();
$this->execute('UPDATE `widget` SET fromDt = 0, toDt = 2147483647;');
}
}

View File

@@ -0,0 +1,80 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 DaypartSystemEntriesAsRecords
*/
class DaypartSystemEntriesAsRecords extends AbstractMigration
{
/**
* @inheritdoc
*/
public function up()
{
$dayPart = $this->table('daypart');
if (!$dayPart->hasColumn('isAlways')) {
$dayPart
->addColumn('isAlways', 'integer', ['default' => 0, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addColumn('isCustom', 'integer', ['default' => 0, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->insert([
[
'name' => 'Custom',
'description' => 'User specifies the from/to date',
'isRetired' => 0,
'userid' => 1,
'startTime' => '',
'endTime' => '',
'exceptions' => '',
'isAlways' => 0,
'isCustom' => 1
], [
'name' => 'Always',
'description' => 'Event runs always',
'isRetired' => 0,
'userid' => 1,
'startTime' => '',
'endTime' => '',
'exceptions' => '',
'isAlways' => 1,
'isCustom' => 0
]
])
->save();
// Execute some SQL to bring the existing records into line.
$this->execute('UPDATE `schedule` SET dayPartId = (SELECT dayPartId FROM daypart WHERE isAlways = 1) WHERE dayPartId = 1');
$this->execute('UPDATE `schedule` SET dayPartId = (SELECT dayPartId FROM daypart WHERE isCustom = 1) WHERE dayPartId = 0');
// Add some default permissions
$this->execute('
INSERT INTO `permission` (entityId, groupId, objectId, view, edit, `delete`)
SELECT entityId, groupId, dayPartId, 1, 0, 0
FROM daypart
CROSS JOIN permissionentity
CROSS JOIN `group`
WHERE entity LIKE \'%DayPart\' AND IsEveryone = 1 AND (isCustom = 1 OR isAlways = 1);
');
}
}
}

View File

@@ -0,0 +1,34 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 MailFromNameSettingMigration extends AbstractMigration
{
/** @inheritdoc */
public function up()
{
// Check to see if the mail_from_name setting exists
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'mail_from_name\'')) {
$this->execute('INSERT INTO setting (setting, value, fieldType, helptext, options, cat, userChange, title, validation, ordering, `default`, userSee, type) VALUES (\'mail_from_name\', \'\', \'text\', \'Mail will be sent under this name\', NULL, \'maintenance\', 1, \'Sending email name\', \'\', 45, \'\', 1, \'string\');');
}
}
}

View File

@@ -0,0 +1,85 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 DisplayGroupClosureIndexToNonUnique extends AbstractMigration
{
/** @inheritdoc */
public function up()
{
// Drop the existing indexes if they exist
$indexName = $this->checkIndexExists('lkdgdg', ['parentId', 'childId', 'depth'], true);
if ($indexName !== false) {
$this->execute('DROP INDEX `' . $indexName . '` ON `lkdgdg`');
}
$indexName = $this->checkIndexExists('lkdgdg', ['childId', 'parentId', 'depth'], true);
if ($indexName !== false) {
$this->execute('DROP INDEX `' . $indexName . '` ON `lkdgdg`');
}
// Add new indexes
$table = $this->table('lkdgdg');
$table
->addIndex(['parentId', 'childId', 'depth'])
->addIndex(['childId', 'parentId', 'depth'])
->update();
}
/**
* Check if an index exists
* @param string $table
* @param string[] $columns
* @param bool $isUnique
* @return string|false
* @throws InvalidArgumentException
*/
private function checkIndexExists($table, $columns, $isUnique)
{
if (!is_array($columns) || count($columns) <= 0)
throw new InvalidArgumentException('Incorrect call to checkIndexExists', 'columns');
// Use the information schema to see if the index exists or not.
// all users have permission to the information schema
$sql = '
SELECT *
FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_schema=DATABASE()
AND table_name = \'' . $table . '\'
AND non_unique = \'' . (($isUnique) ? 0 : 1) . '\'
AND (
';
$i = 0;
foreach ($columns as $column) {
$i++;
$sql .= (($i == 1) ? '' : ' OR') . ' (seq_in_index = \'' . $i . '\' AND column_name = \'' . $column . '\') ';
}
$sql .= ' )';
$indexes = $this->fetchAll($sql);
return (count($indexes) === count($columns)) ? $indexes[0]['INDEX_NAME'] : false;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 DataSetColumnFilterAndSortOptionsMigration
*/
class DataSetColumnFilterAndSortOptionsMigration extends AbstractMigration
{
/**
* Add the show filter and show sort columns if they do not yet exist.
*/
public function change()
{
$table = $this->table('datasetcolumn');
if (!$table->hasColumn('showFilter')) {
$table
->addColumn('showFilter', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 1])
->addColumn('showSort', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 1])
->update();
}
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 WidgetCreatedAndModifiedDtMigration
*/
class WidgetCreatedAndModifiedDtMigration extends AbstractMigration
{
/**
*
*/
public function change()
{
$table = $this->table('widget');
if (!$table->hasColumn('modifiedDt')) {
$table
->addColumn('createdDt', 'integer', ['default' => 0])
->addColumn('modifiedDt', 'integer', ['default' => 0])
->update();
}
}
}

View File

@@ -0,0 +1,45 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 MediaTableEditedIdIndexMigration
* Add EditedMediaId index to the Media table
*/
class MediaTableEditedIdIndexMigration extends AbstractMigration
{
/**
* @inheritdoc
*/
public function change()
{
$this->execute('UPDATE `media` SET createdDt = \'1970-01-01 00:00:00\' WHERE createdDt < \'2000-01-01\'');
$this->execute('UPDATE `media` SET modifiedDt = \'1970-01-01 00:00:00\' WHERE modifiedDt < \'2000-01-01\'');
$table = $this->table('media');
$table
->changeColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->addIndex('editedMediaId')
->update();
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 PlaylistAddDynamicFilterMigration
* add dynamic playlist filtering
*/
class PlaylistAddDynamicFilterMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('playlist');
$this->execute('UPDATE `playlist` SET createdDt = \'1970-01-01 00:00:00\' WHERE createdDt < \'2000-01-01\'');
$this->execute('UPDATE `playlist` SET modifiedDt = \'1970-01-01 00:00:00\' WHERE modifiedDt < \'2000-01-01\'');
$table
->changeColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('isDynamic', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->addColumn('filterMediaName', 'string', ['limit' => 255, 'null' => true, 'default' => null])
->addColumn('filterMediaTags', 'string', ['limit' => 255, 'null' => true, 'default' => null])
->update();
$task = $this->table('task');
$task->insert([
'name' => 'Sync Dynamic Playlists',
'class' => '\Xibo\XTR\DynamicPlaylistSyncTask',
'options' => '[]',
'schedule' => '* * * * * *',
'isActive' => '1',
'configFile' => '/tasks/dynamic-playlist-sync.task'
])
->save();
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 RemoveUserLoggedInMigration
* Removes the logged in column if it still exists.
*/
class RemoveUserLoggedInMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('user');
if ($table->hasColumn('loggedIn')) {
$table->removeColumn('loggedIn')->update();
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 FixCaseOnHelpTextFieldMigration
*/
class FixCaseOnHelpTextFieldMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('setting');
if ($table->hasColumn('helptext')) {
$table->renameColumn('helptext', 'helpText')->save();
}
}
}

View File

@@ -0,0 +1,54 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 LayoutPublishDraftMigration
*/
class LayoutPublishDraftMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Add a status table
$status = $this->table('status');
$status
->addColumn('status', 'string', ['limit' => 254])
->save();
// We must ensure that the IDs are added as we expect (don't rely on auto_increment)
$this->execute('INSERT INTO `status` (`id`, `status`) VALUES (1, \'Published\'), (2, \'Draft\'), (3, \'Pending Approval\')');
$this->execute('UPDATE `layout` SET createdDt = \'1970-01-01 00:00:00\' WHERE createdDt < \'2000-01-01\'');
$this->execute('UPDATE `layout` SET modifiedDt = \'1970-01-01 00:00:00\' WHERE modifiedDt < \'2000-01-01\'');
// Add a reference to the Layout and Playlist tables for "parentId"
$layout = $this->table('layout');
$layout
->changeColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('parentId', 'integer', ['default' => null, 'null' => true])
->addColumn('publishedStatusId', 'integer', ['default' => 1])
->addForeignKey('publishedStatusId', 'status')
->save();
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 DataSetTruncateFixMigration
*/
class DataSetTruncateFixMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('dataset');
if (!$table->hasColumn('lastClear')) {
$table
->addColumn('lastClear', 'integer')
->changeColumn('authentication', 'string', ['limit' => 10, 'default' => null, 'null' => true])
->save();
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 DisplayAsVncLinkMigration
*/
class DisplayAsVncLinkMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$this->query('UPDATE `setting` SET title = \'Add a link to the Display name using this format mask?\', helpText = \'Turn the display name in display management into a link using the IP address last collected. The %s is replaced with the IP address. Leave blank to disable.\' WHERE setting = \'SHOW_DISPLAY_AS_VNCLINK\';');
$this->query('UPDATE `setting` SET title = \'The target attribute for the above link\' WHERE setting = \'SHOW_DISPLAY_AS_VNC_TGT\';');
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 AddWidgetSyncTaskMigration
*/
class AddWidgetSyncTaskMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Check to see if the mail_from_name setting exists
if (!$this->fetchRow('SELECT * FROM `task` WHERE name = \'Widget Sync\'')) {
$this->execute('INSERT INTO `task` SET `name`=\'Widget Sync\', `class`=\'\\\\Xibo\\\\XTR\\\\WidgetSyncTask\', `status`=2, `isActive`=1, `configFile`=\'/tasks/widget-sync.task\', `options`=\'{}\', `schedule`=\'*/3 * * * *\';');
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2018 Spring Signage Ltd
*
* 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 EventLayoutPermissionSettingMigration
*/
class EventLayoutPermissionSettingMigration extends AbstractMigration
{
/** @inheritdoc */
public function up()
{
// Check to see if the mail_from_name setting exists
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'SCHEDULE_SHOW_LAYOUT_NAME\'')) {
$this->execute('INSERT INTO `setting` (`setting`, `value`, `fieldType`, `helptext`, `options`, `cat`, `userChange`, `title`, `validation`, `ordering`, `default`, `userSee`, `type`) VALUES (\'SCHEDULE_SHOW_LAYOUT_NAME\', \'0\', \'checkbox\', \'If checked then the Schedule will show the Layout for existing events even if the logged in User does not have permission to see that Layout.\', null, \'permissions\', 1, \'Show event Layout regardless of User permission?\', \'\', 45, \'\', 1, \'checkbox\');');
}
}
}

View File

@@ -0,0 +1,69 @@
<?php
/**
* Copyright (C) 2018 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 AddForeignKeysToTagsMigration
*/
class AddForeignKeysToTagsMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktagcampaign\' AND referenced_table_name = \'campaign\';')) {
// Delete any records which result in a constraint failure (the records would be orphaned anyway)
$this->execute('DELETE FROM `lktagcampaign` WHERE campaignId NOT IN (SELECT campaignId FROM `campaign`)');
// Add the constraint
$this->execute('ALTER TABLE `lktagcampaign` ADD CONSTRAINT `lktagcampaign_ibfk_1` FOREIGN KEY (`campaignId`) REFERENCES `campaign` (`campaignId`);');
}
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktaglayout\' AND referenced_table_name = \'layout\';')) {
// Delete any records which result in a constraint failure (the records would be orphaned anyway)
$this->execute('DELETE FROM `lktaglayout` WHERE layoutId NOT IN (SELECT layoutId FROM `layout`)');
// Add the constraint
$this->execute('ALTER TABLE `lktaglayout` ADD CONSTRAINT `lktaglayout_ibfk_1` FOREIGN KEY (`layoutId`) REFERENCES `layout` (`layoutId`);');
}
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktagmedia\' AND referenced_table_name = \'media\';')) {
// Delete any records which result in a constraint failure (the records would be orphaned anyway)
$this->execute('DELETE FROM `lktagmedia` WHERE mediaId NOT IN (SELECT mediaId FROM `media`)');
// Add the constraint
$this->execute('ALTER TABLE `lktagmedia` ADD CONSTRAINT `lktagmedia_ibfk_1` FOREIGN KEY (`mediaId`) REFERENCES `media` (`mediaId`);');
}
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktagdisplaygroup\' AND referenced_table_name = \'displaygroup\';')) {
// Delete any records which result in a constraint failure (the records would be orphaned anyway)
$this->execute('DELETE FROM `lktagdisplaygroup` WHERE displayGroupId NOT IN (SELECT displayGroupId FROM `displaygroup`)');
// Add the constraint
$this->execute('ALTER TABLE `lktagdisplaygroup` ADD CONSTRAINT `lktagdisplaygroup_ibfk_1` FOREIGN KEY (`displayGroupId`) REFERENCES `displaygroup` (`displayGroupId`);');
}
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* Copyright (C) 2018 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 AddForeignKeysToPermissionsMigration
*/
class AddForeignKeysToPermissionsMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'permission\' AND referenced_table_name = \'group\';')) {
// Delete any records which result in a constraint failure (the records would be orphaned anyway)
$this->execute('DELETE FROM `permission` WHERE groupId NOT IN (SELECT groupId FROM `group`)');
// Add the constraint
$this->execute('ALTER TABLE `permission` ADD CONSTRAINT `permission_ibfk_1` FOREIGN KEY (`groupId`) REFERENCES `group` (`groupId`);');
}
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'permission\' AND referenced_table_name = \'permissionentity\';')) {
// Delete any records which result in a constraint failure (the records would be orphaned anyway)
$this->execute('DELETE FROM `permission` WHERE entityId NOT IN (SELECT entityId FROM `permissionentity`)');
// Add the constraint
$this->execute('ALTER TABLE `permission` ADD CONSTRAINT `permission_ibfk_2` FOREIGN KEY (`entityId`) REFERENCES `permissionentity` (`entityId`);');
}
// Index
if (!$this->checkIndexExists('permission', ['objectId'], 0)) {
$this->execute('CREATE INDEX permission_objectId_index ON permission (objectId);');
}
}
/**
* Check if an index exists
* @param string $table
* @param string[] $columns
* @param bool $isUnique
* @return bool
* @throws InvalidArgumentException
*/
private function checkIndexExists($table, $columns, $isUnique)
{
if (!is_array($columns) || count($columns) <= 0)
throw new InvalidArgumentException('Incorrect call to checkIndexExists', 'columns');
// Use the information schema to see if the index exists or not.
// all users have permission to the information schema
$sql = '
SELECT *
FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_schema=DATABASE()
AND table_name = \'' . $table . '\'
AND non_unique = \'' . (($isUnique) ? 0 : 1) . '\'
AND (
';
$i = 0;
foreach ($columns as $column) {
$i++;
$sql .= (($i == 1) ? '' : ' OR') . ' (seq_in_index = \'' . $i . '\' AND column_name = \'' . $column . '\') ';
}
$sql .= ' )';
$indexes = $this->fetchAll($sql);
return (count($indexes) === count($columns));
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Copyright (C) 2018 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 AddForeignKeysToWidgetMediaMigration
*/
class AddForeignKeysToWidgetMediaMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lkwidgetmedia\' AND referenced_table_name = \'media\';')) {
$this->execute('DELETE FROM `lkwidgetmedia` WHERE NOT EXISTS (SELECT mediaId FROM `media` WHERE `media`.mediaId = `lkwidgetmedia`.mediaId) ');
// Add the constraint
$this->execute('ALTER TABLE `lkwidgetmedia` ADD CONSTRAINT `lkwidgetmedia_ibfk_1` FOREIGN KEY (`mediaId`) REFERENCES `media` (`mediaId`);');
}
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lkwidgetmedia\' AND referenced_table_name = \'widget\';')) {
$this->execute('DELETE FROM `lkwidgetmedia` WHERE NOT EXISTS (SELECT widgetId FROM `widget` WHERE `widget`.widgetId = `lkwidgetmedia`.widgetId) ');
// Add the constraint
$this->execute('ALTER TABLE `lkwidgetmedia` ADD CONSTRAINT `lkwidgetmedia_ibfk_2` FOREIGN KEY (`widgetId`) REFERENCES `widget` (`widgetId`);');
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* Copyright (C) 2018 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 ForgottenPasswordReminderMigration
*/
class ForgottenPasswordReminderMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'DEFAULT_USERGROUP\'')) {
$this->execute('
INSERT INTO `setting` (`setting`, `value`, `fieldType`, `helptext`, `options`, `cat`, `userChange`, `title`, `validation`, `ordering`, `default`, `userSee`, `type`)
VALUES (\'DEFAULT_USERGROUP\', \'1\', \'text\', \'The default User Group for new Users\', \'1\', \'users\', 1, \'Default User Group\', \'\', 4, \'\', 1, \'int\');
');
}
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'PASSWORD_REMINDER_ENABLED\'')) {
$this->execute('
INSERT INTO `setting` (`setting`, `value`, `fieldType`, `helptext`, `options`, `cat`, `userChange`, `title`, `validation`, `ordering`, `default`, `userSee`, `type`)
VALUES (\'PASSWORD_REMINDER_ENABLED\', \'Off\', \'dropdown\', \'Is password reminder enabled?\', \'On|On except Admin|Off\', \'users\', 1, \'Password Reminder\', \'\', 50, \'Off\', 1, \'string\');
');
}
$table = $this->table('user');
if (!$table->hasColumn('isPasswordChangeRequired')) {
$table
->addColumn('isPasswordChangeRequired', 'integer',
['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 0])
->save();
}
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Copyright (C) 2018 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 DataSetRssMigration
*/
class DataSetRssMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
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();
}
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* Copyright (C) 2018 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 SimpleSettingsMigration
*/
class SimpleSettingsMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Update all of our old "Checked|Unchecked" boxes to be proper checkboxes
$this->execute('UPDATE `setting` SET `value` = 0 WHERE `value` = \'Unchecked\'');
$this->execute('UPDATE `setting` SET `value` = 1 WHERE `value` = \'Checked\'');
// Update all of our old "Yes|No" boxes to be proper checkboxes
$this->execute('UPDATE `setting` SET `value` = 0 WHERE `value` = \'No\'');
$this->execute('UPDATE `setting` SET `value` = 1 WHERE `value` = \'Yes\'');
// Update all of our old "Off|On" boxes to be proper checkboxes (unless there are more than 2 options)
$this->execute('UPDATE `setting` SET `value` = 0 WHERE `value` = \'Off\' AND `setting` NOT IN (\'MAINTENANCE_ENABLED\', \'PASSWORD_REMINDER_ENABLED\', \'SENDFILE_MODE\')');
$this->execute('UPDATE `setting` SET `value` = 1 WHERE `value` = \'On\' AND `setting` NOT IN (\'MAINTENANCE_ENABLED\', \'PASSWORD_REMINDER_ENABLED\')');
$table = $this->table('setting');
$table
->removeColumn('type')
->removeColumn('title')
->removeColumn('default')
->removeColumn('fieldType')
->removeColumn('helpText')
->removeColumn('options')
->removeColumn('cat')
->removeColumn('validation')
->removeColumn('ordering')
->save();
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Copyright (C) 2018 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 RemoveFinanceModuleMigration
*/
class RemoveFinanceModuleMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Delete the finance module from the modules table.
$this->execute('DELETE FROM module WHERE `module` = \'finance\'');
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Copyright (C) 2018 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 SplitTickerModuleMigration
*/
class SplitTickerModuleMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Add the new module.
$this->execute('
INSERT INTO `module`
(`Module`, `Name`, `Enabled`, `RegionSpecific`, `Description`, `ImageUri`, `SchemaVersion`, `ValidExtensions`, `PreviewEnabled`, `assignable`, `render_as`, `settings`, `viewPath`, `class`, `defaultDuration`)
VALUES
(\'datasetticker\', \'DataSet Ticker\', 1, 1, \'Ticker with a DataSet providing the items\', \'forms/ticker.gif\', 1, NULL, 1, 1, \'html\', NULL, \'../modules\', \'Xibo\\\\Widget\\\\DataSetTicker\', 10);
');
// Find all of the existing tickers which have a dataSet source, and update them to point at the new
// module `datasetticker`
$this->execute('
UPDATE `widget` SET type = \'datasetticker\' WHERE type = \'ticker\' AND widgetId IN (SELECT DISTINCT widgetId FROM `widgetoption` WHERE `option` = \'sourceId\' AND `value` = \'2\')
');
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Copyright (C) 2018 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 Release1812Migration
* applicable changes from 143.json
*/
class Release1812Migration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Add a setting allowing users to auto authorise new displays
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\'');
// Change the DataSet View module name
$this->execute('UPDATE `module` set Name = \'DataSet View\' WHERE `Module` = \'datasetview\'');
// Add M4V extension to Video module
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;');
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* Copyright (C) 2018 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 RemoveImageUriModuleMigration
* Remove the imageUri column from modules table
*/
class RemoveImageUriModuleMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('module');
if ($table->hasColumn('imageUri')) {
$table->removeColumn('imageUri')->update();
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Copyright (C) 2018 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 CreatePlayerVersionsTableMigration
* Create a new table to store information about player versions
* Install playersoftware widget
* Remove apk,ipk from validExtensions in genericfiles module
*/
class CreatePlayerVersionsTableMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
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');
if (!$this->fetchRow('SELECT * FROM module WHERE module = \'playersoftware\'')) {
$modules->insert([
'module' => 'playersoftware',
'name' => 'Player Software',
'enabled' => 1,
'regionSpecific' => 0,
'description' => 'A module for managing Player Versions',
'schemaVersion' => 1,
'validExtensions' => 'apk,ipk,wgt',
'previewEnabled' => 0,
'assignable' => 0,
'render_as' => null,
'viewPath' => '../modules',
'class' => 'Xibo\Widget\PlayerSoftware',
'defaultDuration' => 10
])->save();
}
// remove apk and ipk from valid extensions in generic file module
$this->execute('UPDATE `module` SET validextensions = REPLACE(validextensions, \'apk,ipk\', \'\') WHERE module = \'genericfile\' LIMIT 1;');
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Copyright (C) 2018 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 EventSyncMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Add a setting allowing users enable event sync on applicable events
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'EVENT_SYNC\'')) {
$this->table('setting')->insert([
[
'setting' => 'EVENT_SYNC',
'value' => 0,
'userSee' => 0,
'userChange' => 0
]
])->save();
}
$scheduleTable = $this->table('schedule');
if (!$scheduleTable->hasColumn('syncEvent')) {
$scheduleTable
->addColumn('syncEvent', 'integer', ['default' => 0, 'null' => false])
->save();
}
}
}

View File

@@ -0,0 +1,82 @@
<?php
/**
* Copyright (C) 2018 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 PlayerUpgradeAndOverrideConfigMigration
* Add Player Software to Pages
* Remove version_instructions column from Display table
* Add overrideConfig column to display table
* Add default profile for Tizen
*/
class PlayerUpgradeAndOverrideConfigMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$pages = $this->table('pages');
$displayTable = $this->table('display');
$displayProfileTable = $this->table('displayprofile');
// add Player Software page
if (!$this->fetchRow('SELECT * FROM pages WHERE name = \'playersoftware\'')) {
$pages->insert([
'name' => 'playersoftware',
'title' => 'Player Software',
'asHome' => 0
])->save();
}
$displayTableModified = false;
// remove version_instructions from display table
if ($displayTable->hasColumn('version_instructions')) {
$displayTable->removeColumn('version_instructions');
$displayTableModified = true;
}
// add overrideConfig column to display table
if (!$displayTable->hasColumn('overrideConfig')) {
$displayTable->addColumn('overrideConfig', 'text');
$displayTableModified = true;
}
if ($displayTableModified) {
$displayTable->save();
}
// Get system user
$user = $this->fetchRow("SELECT userId FROM `user` WHERE userTypeId = 1");
// add default display profile for tizen
if (!$this->fetchRow('SELECT * FROM displayprofile WHERE type = \'sssp\' AND isDefault = 1')) {
$displayProfileTable->insert([
'name' => 'Tizen',
'type' => 'sssp',
'config' => '[]',
'userId' => $user['userId'],
'isDefault' => 1
])->save();
}
}
}

View File

@@ -0,0 +1,41 @@
<?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 PlayerSoftwareVersionFieldMigration
*/
class PlayerSoftwareVersionFieldMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('player_software');
if (!$table->hasColumn('playerShowVersion')) {
$table
->addColumn('playerShowVersion', 'string', ['limit' => 50])
->save();
}
}
}

View File

@@ -0,0 +1,48 @@
<?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 AddLinuxDisplayProfileMigration
*/
class AddLinuxDisplayProfileMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Check to see if we already have a Linux default display profile. if not, add it.
if (!$this->fetchRow('SELECT * FROM displayprofile WHERE type = \'linux\' AND isDefault = 1')) {
// Get system user
$user = $this->fetchRow('SELECT userId FROM `user` WHERE userTypeId = 1');
$table = $this->table('displayprofile');
$table->insert([
'name' => 'Linux',
'type' => 'linux',
'config' => '[]',
'userId' => $user['userId'],
'isDefault' => 1
])->save();
}
}
}

View File

@@ -0,0 +1,35 @@
<?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 AddProofOfPlayStatsDurationAndCountMigration
*/
class AddProofOfPlayStatsDurationAndCountMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Removed from here to streamline the upgrade from 2.0 to 2.1
}
}

View File

@@ -0,0 +1,23 @@
<?php
use Phinx\Migration\AbstractMigration;
class AddDefaultTransitionDurationSettingMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Add a setting allowing users enable event sync on applicable events
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'DEFAULT_TRANSITION_DURATION\'')) {
$this->table('setting')->insert([
[
'setting' => 'DEFAULT_TRANSITION_DURATION',
'value' => 1000,
'userSee' => 1,
'userChange' => 1
]
])->save();
}
}
}

View File

@@ -0,0 +1,89 @@
<?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 AddGlobalStatSettingMigration
*/
class AddGlobalStatSettingMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$dateTime = new \DateTime();
$earlierMonth = $dateTime->modify( '-1 month' )->format( 'Y-m-d' );
$result = $this->fetchRow('SELECT EXISTS (SELECT * FROM `stat` where `stat`.end > \'' . $earlierMonth . '\' LIMIT 1)');
$table = $this->table('setting');
// if there are no stats recorded in last 1 month then layout stat is Off
if ($result[0] <= 0 ) {
$table
->insert([
[
'setting' => 'LAYOUT_STATS_ENABLED_DEFAULT',
'value' => 0,
'userSee' => 1,
'userChange' => 1
]
])
->save();
} else {
$table
->insert([
[
'setting' => 'LAYOUT_STATS_ENABLED_DEFAULT',
'value' => 1,
'userSee' => 1,
'userChange' => 1
]
])
->save();
}
// Media and widget stat is always set to Inherit
$table
->insert([
[
'setting' => 'DISPLAY_PROFILE_AGGREGATION_LEVEL_DEFAULT',
'value' => 'Individual',
'userSee' => 1,
'userChange' => 1
],
[
'setting' => 'MEDIA_STATS_ENABLED_DEFAULT',
'value' => 'Inherit',
'userSee' => 1,
'userChange' => 1
],
[
'setting' => 'WIDGET_STATS_ENABLED_DEFAULT',
'value' => 'Inherit',
'userSee' => 1,
'userChange' => 1
]
])
->save();
}
}

View File

@@ -0,0 +1,45 @@
<?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 AddHorizontalMenuSettingMigration
*/
class AddHorizontalMenuSettingMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Add a setting allowing users enable event sync on applicable events
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'NAVIGATION_MENU_POSITION\'')) {
$this->table('setting')->insert([
[
'setting' => 'NAVIGATION_MENU_POSITION',
'value' => 'vertical',
'userSee' => 1,
'userChange' => 1
]
])->save();
}
}
}

View File

@@ -0,0 +1,43 @@
<?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 AddLayoutEnableStat
*/
class AddLayoutEnableStat extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$this->execute('UPDATE `layout` SET createdDt = \'1970-01-01 00:00:00\' WHERE createdDt < \'2000-01-01\'');
$this->execute('UPDATE `layout` SET modifiedDt = \'1970-01-01 00:00:00\' WHERE modifiedDt < \'2000-01-01\'');
$table = $this->table('layout');
$table
->changeColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('enableStat', 'integer', ['null' => true])
->save();
}
}

View File

@@ -0,0 +1,43 @@
<?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 AddMediaEnableStat
*/
class AddMediaEnableStat extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$this->execute('UPDATE `media` SET createdDt = \'1970-01-01 00:00:00\' WHERE createdDt < \'2000-01-01\'');
$this->execute('UPDATE `media` SET modifiedDt = \'1970-01-01 00:00:00\' WHERE modifiedDt < \'2000-01-01\'');
$table = $this->table('media');
$table
->changeColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('enableStat', 'string', ['null' => true])
->save();
}
}

View File

@@ -0,0 +1,38 @@
<?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 AddScheduleRecurrenceMonthlyRepeatsOnMigration
*/
class AddScheduleRecurrenceMonthlyRepeatsOnMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('schedule');
$table
->addColumn('recurrenceMonthlyRepeatsOn', 'integer', ['default' => 0, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->save();
}
}

View File

@@ -0,0 +1,62 @@
<?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 */
public function change()
{
// query the database and look for duplicate entries
$duplicatesData = $this->query('SELECT displayId, license FROM display WHERE license IN ( SELECT license FROM display GROUP BY license HAVING count(*) > 1) GROUP BY displayId;');
$rowsDuplicatesData = $duplicatesData->fetchAll(PDO::FETCH_ASSOC);
// only execute this code if any duplicates were found
if (count($rowsDuplicatesData) > 0) {
$licences = [];
$filtered = [];
// create new array with license as the key
foreach ($rowsDuplicatesData as $row) {
$licences[$row['license']][] = $row['displayId'];
}
// iterate through the array and remove first element from each of the arrays with displayIds
foreach ($licences as $licence) {
array_shift($licence);
$filtered[] = $licence;
}
// iterate through our new filtered array, that only contains displayIds that should be removed and execute the SQL DELETE statements
foreach ($filtered as $item) {
foreach ($item as $displayId) {
$this->execute('DELETE FROM lkdisplaydg WHERE displayId = ' . $displayId);
$this->execute('DELETE FROM display WHERE `displayId` = ' . $displayId);
}
}
}
// add unique index to license column
$table = $this->table('display');
$table->addIndex(['license'], ['unique' => true])->update();
}
}

View File

@@ -0,0 +1,38 @@
<?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 */
public function change()
{
$table = $this->table('displaygroup');
$table
->addColumn('dynamicCriteriaTags', 'string', ['limit' => 254, 'default' => null, 'null' => true])
->save();
}
}

View File

@@ -0,0 +1,60 @@
<?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 */
public function change()
{
// get the current validExtensions for genericfile module
$extensionsData = $this->query('SELECT `validExtensions` FROM `module` WHERE `Module` = \'genericfile\';');
$extensions = $extensionsData->fetchAll(PDO::FETCH_ASSOC);
$newExtensions = [];
//iterate through the array
foreach ($extensions as $extension) {
foreach ($extension as $validExt) {
// make an array out of comma separated string
$explode = explode(',', $validExt);
// iterate through our array, remove apk and ipk extensions from it and put them in a new array
foreach ($explode as $item) {
if ($item != 'apk' && $item != 'ipk') {
$newExtensions[] = $item;
}
}
}
}
// make a comma separated string from our new array
$newValidExtensions = implode(',', $newExtensions);
// update validExtensions for genericfile module with our adjusted extensions
$this->execute('UPDATE `module` SET `validExtensions` = \'' . $newValidExtensions . '\' WHERE module = \'genericfile\' LIMIT 1;');
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* Copyright (C) 2018 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 AddBandwidthLimitColumnToDisplaygroupMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$displayGroupTable = $this->table('displaygroup');
if (!$displayGroupTable->hasColumn('bandwidthLimit')) {
$displayGroupTable
->addColumn('bandwidthLimit', 'integer', ['default' => 0, 'null' => false])
->save();
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Copyright (C) 2018 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 AddPublishedDateColumnMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$layoutTable = $this->table('layout');
if (!$layoutTable->hasColumn('publishedDate')) {
$this->execute('UPDATE `layout` SET createdDt = \'1970-01-01 00:00:00\' WHERE createdDt < \'2000-01-01\'');
$this->execute('UPDATE `layout` SET modifiedDt = \'1970-01-01 00:00:00\' WHERE modifiedDt < \'2000-01-01\'');
$layoutTable
->changeColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('publishedDate', 'datetime', ['null' => true, 'default' => null])
->save();
}
}
}

View File

@@ -0,0 +1,57 @@
<?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 CreateLayoutHistoryTableMigration
*/
class CreateLayoutHistoryTableMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('layouthistory', ['id' => 'layoutHistoryId']);
$table->addColumn('campaignId', 'integer')
->addColumn('layoutId', 'integer')
->addColumn('publishedDate', 'datetime', ['null' => true, 'default' => null])
->addForeignKey('campaignId', 'campaign', 'campaignId')
->create();
// insert all published layoutIds and their corresponding campaignId in the layouthistory
$this->execute('INSERT INTO `layouthistory` (campaignId, layoutId, publishedDate)
SELECT T.campaignId, L.layoutId, L.modifiedDt
FROM layout L
INNER JOIN
(SELECT
lkc.layoutId, lkc.campaignId
FROM
`campaign` C
INNER JOIN `lkcampaignlayout` lkc
ON C.campaignId = lkc.campaignId
WHERE
isLayoutSpecific = 1) T
ON T.layoutId = L.layoutId
WHERE
L.parentId IS NULL;');
}
}

View File

@@ -0,0 +1,35 @@
<?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 AddCampaignStatMigration
*/
class AddCampaignStatMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Removed from here to streamline the upgrade from 2.0 to 2.1
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Copyright (C) 2018 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 AddScheduleNowPageMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$pages = $this->table('pages');
// add schedule now page
if (!$this->fetchRow('SELECT * FROM pages WHERE name = \'schedulenow\'')) {
$pages->insert([
'name' => 'schedulenow',
'title' => 'Schedule Now',
'asHome' => 0
])->save();
}
// add permission to the schedule now page to every group and user, excluding "Everyone"
$permissions = $this->table('permission');
$scheduleNowPageId = $this->fetchRow('SELECT pageId FROM `pages` WHERE `name` = \'schedulenow\' ');
$groupIds = $this->fetchAll('SELECT groupId FROM `group` WHERE `isEveryone` = 0 ');
foreach ($groupIds as $groupId) {
$permissions->insert([
[
'entityId' => 1,
'groupId' => $groupId['groupId'],
'objectId' => $scheduleNowPageId[0],
'view' => 1,
'edit' => 0,
'delete' => 0
]
])->save();
}
}
}

View File

@@ -0,0 +1,45 @@
<?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 CreateReportScheduleTableMigration
*/
class CreateReportScheduleTableMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('reportschedule', ['id' => 'reportScheduleId']);
$table->addColumn('name', 'string')
->addColumn('reportName', 'string')
->addColumn('filterCriteria', 'text')
->addColumn('schedule', 'string')
->addColumn('lastRunDt', 'integer', ['default' => 0])
->addColumn('userId', 'integer')
->addColumn('createdDt', 'integer')
->addForeignKey('userId', 'user', 'userId')
->save();
}
}

View File

@@ -0,0 +1,45 @@
<?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 CreateSavedReportTableMigration
*/
class CreateSavedReportTableMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('saved_report', ['id' => 'savedReportId']);
$table->addColumn('saveAs', 'string')
->addColumn('reportName', 'string')
->addColumn('mediaId', 'integer')
->addColumn('reportScheduleId', 'integer')
->addColumn('generatedOn', 'integer')
->addColumn('userId', 'integer')
->addForeignKey('userId', 'user', 'userId')
->addForeignKey('mediaId', 'media', 'mediaId')
->addForeignKey('reportScheduleId', 'reportschedule', 'reportScheduleId')
->save();
}
}

View File

@@ -0,0 +1,44 @@
<?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 AddReportPageMigration
*/
class AddReportPageMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$pages = $this->table('pages');
// add report page
if (!$this->fetchRow('SELECT * FROM pages WHERE name = \'report\'')) {
$pages->insert([
'name' => 'report',
'title' => 'Report',
'asHome' => 0
])->save();
}
}
}

View File

@@ -0,0 +1,52 @@
<?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 TwoFactorAuthMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$userTable = $this->table('user');
if (!$userTable->hasColumn('twoFactorTypeId')) {
$userTable
->addColumn('twoFactorTypeId', 'integer', ['default' => 0, 'null' => false])
->addColumn('twoFactorSecret', 'text', ['default' => NULL, 'null' => true])
->addColumn('twoFactorRecoveryCodes', 'text', ['default' => NULL, 'null' => true])
->save();
}
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'TWOFACTOR_ISSUER\'')) {
$this->table('setting')->insert([
[
'setting' => 'TWOFACTOR_ISSUER',
'value' => '',
'userSee' => 1,
'userChange' => 1
]
])->save();
}
}
}

View File

@@ -0,0 +1,37 @@
<?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 NullableTextFieldsMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$notNullableTextColumnsQuery = $this->query('SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = \'text\' AND IS_NULLABLE = \'NO\' AND TABLE_SCHEMA = DATABASE() ' );
$notNullableTextColumns = $notNullableTextColumnsQuery->fetchAll(PDO::FETCH_ASSOC);
foreach ($notNullableTextColumns as $columns) {
$this->execute('ALTER TABLE ' . $columns['TABLE_NAME'] . ' MODIFY ' . $columns['COLUMN_NAME'] . ' TEXT NULL;');
}
}
}

View File

@@ -0,0 +1,39 @@
<?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 AddHtmlDatatypeMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
if (!$this->fetchRow('SELECT * FROM `datatype` WHERE dataType = \'HTML\'')) {
$this->table('datatype')->insert([
[
'dataTypeId' => 6,
'dataType' => 'HTML'
]
])->save();
}
}
}

View File

@@ -0,0 +1,122 @@
<?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 InstallAdditionalStandardModulesMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$modules = $this->table('module');
if (!$this->fetchRow('SELECT * FROM module WHERE module = \'htmlpackage\'')) {
$modules->insert([
'module' => 'htmlpackage',
'name' => 'HTML Package',
'enabled' => 1,
'regionSpecific' => 0,
'description' => 'Upload a complete package to distribute to Players',
'schemaVersion' => 1,
'validExtensions' => 'htz',
'previewEnabled' => 0,
'assignable' => 1,
'render_as' => 'native',
'viewPath' => '../modules',
'class' => 'Xibo\Widget\HtmlPackage',
'defaultDuration' => 60
])->save();
}
if (!$this->fetchRow('SELECT * FROM module WHERE module = \'videoin\'')) {
$modules->insert([
'module' => 'videoin',
'name' => 'Video In',
'enabled' => 1,
'regionSpecific' => 1,
'description' => 'Display input from an external source',
'schemaVersion' => 1,
'validExtensions' => null,
'previewEnabled' => 0,
'assignable' => 1,
'render_as' => 'native',
'viewPath' => '../modules',
'class' => 'Xibo\Widget\VideoIn',
'defaultDuration' => 60
])->save();
}
if (!$this->fetchRow('SELECT * FROM module WHERE module = \'hls\'')) {
$modules->insert([
'module' => 'hls',
'name' => 'HLS',
'enabled' => 1,
'regionSpecific' => 1,
'description' => 'Display live streamed content',
'schemaVersion' => 1,
'validExtensions' => null,
'previewEnabled' => 1,
'assignable' => 1,
'render_as' => 'html',
'viewPath' => '../modules',
'class' => 'Xibo\Widget\Hls',
'defaultDuration' => 60
])->save();
}
if (!$this->fetchRow('SELECT * FROM module WHERE module = \'calendar\'')) {
$modules->insert([
'module' => 'calendar',
'name' => 'Calendar',
'enabled' => 1,
'regionSpecific' => 1,
'description' => 'Display events from an iCAL feed',
'schemaVersion' => 1,
'validExtensions' => null,
'previewEnabled' => 1,
'assignable' => 1,
'render_as' => 'html',
'viewPath' => '../modules',
'class' => 'Xibo\Widget\Calendar',
'defaultDuration' => 60
])->save();
}
if (!$this->fetchRow('SELECT * FROM module WHERE module = \'chart\'')) {
$modules->insert([
'module' => 'chart',
'name' => 'Chart',
'enabled' => 1,
'regionSpecific' => 1,
'description' => 'Display information held in a DataSet as a type of Chart',
'schemaVersion' => 1,
'validExtensions' => null,
'previewEnabled' => 1,
'assignable' => 1,
'render_as' => 'html',
'viewPath' => '../modules',
'class' => 'Xibo\Widget\Chart',
'defaultDuration' => 240
])->save();
}
}
}

View File

@@ -0,0 +1,95 @@
<?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 AddForeignKeysToLktagTablesMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
//lktagcampaign
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktagcampaign\' AND referenced_table_name = \'campaign\';')) {
$this->execute('DELETE FROM `lktagcampaign` WHERE NOT EXISTS (SELECT campaignId FROM `campaign` WHERE `campaign`.campaignId = `lktagcampaign`.campaignId) ');
// Add the constraint
$this->execute('ALTER TABLE `lktagcampaign` ADD CONSTRAINT `lktagcampaign_ibfk_2` FOREIGN KEY (`campaignId`) REFERENCES `campaign` (`campaignId`);');
}
//lktagdisplaygroup
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktagdisplaygroup\' AND referenced_table_name = \'displaygroup\';')) {
$this->execute('DELETE FROM `lktagdisplaygroup` WHERE NOT EXISTS (SELECT displayGroupId FROM `displaygroup` WHERE `displaygroup`.displayGroupId = `lktagdisplaygroup`.displayGroupId) ');
// Add the constraint
$this->execute('ALTER TABLE `lktagdisplaygroup` ADD CONSTRAINT `lktagdisplaygroup_ibfk_2` FOREIGN KEY (`displayGroupId`) REFERENCES `displaygroup` (`displayGroupId`);');
}
//lktaglayout
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktaglayout\' AND referenced_table_name = \'layout\';')) {
$this->execute('DELETE FROM `lktaglayout` WHERE NOT EXISTS (SELECT layoutId FROM `layout` WHERE `layout`.layoutId = `lktaglayout`.layoutId) ');
// Add the constraint
$this->execute('ALTER TABLE `lktaglayout` ADD CONSTRAINT `lktaglayout_ibfk_2` FOREIGN KEY (`layoutId`) REFERENCES `layout` (`layoutId`);');
}
//lktagmedia
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktagmedia\' AND referenced_table_name = \'media\';')) {
$this->execute('DELETE FROM `lktagmedia` WHERE NOT EXISTS (SELECT mediaId FROM `media` WHERE `media`.mediaId = `lktagmedia`.mediaId) ');
// Add the constraint
$this->execute('ALTER TABLE `lktagmedia` ADD CONSTRAINT `lktagmedia_ibfk_2` FOREIGN KEY (`mediaId`) REFERENCES `media` (`mediaId`);');
}
//lktagplaylist
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktagplaylist\' AND referenced_table_name = \'tag\';')) {
$this->execute('DELETE FROM `lktagplaylist` WHERE NOT EXISTS (SELECT tagId FROM `tag` WHERE `tag`.tagId = `lktagplaylist`.tagId) ');
// Add the constraint
$this->execute('ALTER TABLE `lktagplaylist` ADD CONSTRAINT `lktagplaylist_ibfk_1` FOREIGN KEY (`tagId`) REFERENCES `tag` (`tagId`);');
}
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'lktagplaylist\' AND referenced_table_name = \'playlist\';')) {
$this->execute('DELETE FROM `lktagplaylist` WHERE NOT EXISTS (SELECT playlistId FROM `playlist` WHERE `playlist`.playlistId = `lktagplaylist`.playlistId) ');
// Add the constraint
$this->execute('ALTER TABLE `lktagplaylist` ADD CONSTRAINT `lktagplaylist_ibfk_2` FOREIGN KEY (`playlistId`) REFERENCES `playlist` (`playlistId`);');
}
}
}

View File

@@ -0,0 +1,47 @@
<?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 AddReportScheduleTaskMigration
*/
class AddReportScheduleTaskMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('task');
if (!$this->fetchRow('SELECT * FROM `task` WHERE name = \'Report Schedule\'')) {
$table->insert([
[
'name' => 'Report Schedule',
'class' => '\Xibo\XTR\ReportScheduleTask',
'options' => '[]',
'schedule' => '*/5 * * * * *',
'isActive' => '1',
'configFile' => '/tasks/report-schedule.task'
],
])->save();
}
}
}

View File

@@ -0,0 +1,39 @@
<?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 AddPreviousRunDateReportScheduleMigration
*/
class AddPreviousRunDateReportScheduleMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('reportschedule');
$table
->addColumn('previousRunDt', 'integer', ['default' => 0, 'after' => 'lastRunDt'])
->addColumn('lastSavedReportId', 'integer', ['default' => 0, 'after' => 'schedule'])
->save();
}
}

View File

@@ -0,0 +1,43 @@
<?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 PlaylistDurationUpdateAtTimestamp
*/
class PlaylistDurationUpdateAtTimestamp extends AbstractMigration
{
/** @inheritDoc */
public function change()
{
$this->execute('UPDATE `playlist` SET createdDt = \'1970-01-01 00:00:00\' WHERE createdDt < \'2000-01-01\'');
$this->execute('UPDATE `playlist` SET modifiedDt = \'1970-01-01 00:00:00\' WHERE modifiedDt < \'2000-01-01\'');
$table = $this->table('playlist');
$table
->changeColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('requiresDurationUpdate', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_REGULAR, 'default' => 0, 'null' => false])
->save();
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 AddPreviousRunDateReportScheduleMigration
*/
class ChangeStatTableStartEndColumnMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$this->table('stat')->rename('stat_archive')->save();
}
}

View File

@@ -0,0 +1,58 @@
<?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 TagsWithValuesMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$tagTable = $this->table('tag');
// add new columns to the tag table
if (!$tagTable->hasColumn('isSystem')) {
$tagTable
->addColumn('isSystem', 'integer', ['default' => 0, 'null' => false])
->addColumn('options', 'text', ['default' => null, 'null' => true])
->addColumn('isRequired', 'integer', ['default' => 0, 'null' => false])
->save();
}
// set isSystem flag on these tags
$this->execute('UPDATE `tag` SET `isSystem` = 1 WHERE tag IN (\'template\', \'background\', \'thumbnail\', \'imported\')');
// add value column to lktag tables
$lktagTables = ["lktagcampaign", "lktagdisplaygroup", "lktaglayout", "lktagmedia", "lktagplaylist"];
foreach ($lktagTables as $lktagTable) {
$table = $this->table($lktagTable);
if(!$table->hasColumn('value')) {
$table
->addColumn('value', 'text', ['default' => null, 'null' => true])
->save();
}
}
}
}

View File

@@ -0,0 +1,35 @@
<?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 RemoveOldVersionTableMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
if ($this->hasTable('version')) {
$this->execute('DROP TABLE version');
}
}
}

View File

@@ -0,0 +1,52 @@
<?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 DisplayTableDatabaseSchemaAdjustmentsMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// nullable and default values adjusted
$this->execute('ALTER TABLE display MODIFY `lastaccessed` int(11) NULL DEFAULT NULL');
$this->execute('ALTER TABLE display MODIFY `license` varchar(40) NULL DEFAULT NULL');
$this->execute('ALTER TABLE display MODIFY `alert_timeout` int(11) DEFAULT 0');
$this->execute('ALTER TABLE display MODIFY `clientAddress` varchar(50) NULL DEFAULT NULL');
$this->execute('ALTER TABLE display MODIFY `macAddress` varchar(254) NULL DEFAULT NULL');
$this->execute('ALTER TABLE display MODIFY `lastChanged` int(11) NULL DEFAULT NULL');
$this->execute('ALTER TABLE display MODIFY `numberOfMacAddressChanges` int(11) DEFAULT 0');
$this->execute('ALTER TABLE display MODIFY `lastWakeOnLanCommandSent` int(11) NULL DEFAULT NULL');
$this->execute('ALTER TABLE display MODIFY `email_alert` int(11) DEFAULT 0');
// display profile foreign key
if (!$this->fetchRow('
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE constraint_schema=DATABASE()
AND `table_name` = \'display\' AND referenced_table_name = \'displayprofile\';')) {
$this->execute('UPDATE `display` SET displayProfileId = NULL WHERE NOT EXISTS (SELECT displayProfileId FROM `displayprofile` WHERE `displayprofile`.displayProfileId = `display`.displayProfileId)');
// Add the constraint
$this->execute('ALTER TABLE `display` ADD CONSTRAINT `display_ibfk_1` FOREIGN KEY (`displayProfileId`) REFERENCES `displayprofile` (`displayProfileId`);');
}
}
}

View File

@@ -0,0 +1,54 @@
<?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 MoveTidyStatsToStatsArchiveTaskMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// query the database and look for Stats Archive task
$statsArchiveQuery = $this->query('SELECT taskId, name, options, isActive FROM `task` WHERE `name` = \'Stats Archive\' ;');
$statsArchiveData = $statsArchiveQuery->fetchAll(PDO::FETCH_ASSOC);
if (count($statsArchiveData) > 0) {
foreach ($statsArchiveData as $row) {
$taskId = $row['taskId'];
$isActive = $row['isActive'];
$options = json_decode($row['options']);
// if the task is current set as Active, we need to ensure that archiveStats option is set to On (default is Off)
if ($isActive == 1) {
$options->archiveStats = 'On';
} else {
$options->archiveStats = 'Off';
}
// save updated options to variable
$newOptions = json_encode($options);
$this->execute('UPDATE `task` SET isActive = 1, options = \'' . $newOptions . '\' WHERE taskId = '. $taskId );
}
}
}
}

View File

@@ -0,0 +1,58 @@
<?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 AddPlaylistEnableStatMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$playlistTable = $this->table('playlist');
if (!$playlistTable->hasColumn('enableStat')) {
$this->execute('UPDATE `playlist` SET createdDt = \'1970-01-01 00:00:00\' WHERE createdDt < \'2000-01-01\'');
$this->execute('UPDATE `playlist` SET modifiedDt = \'1970-01-01 00:00:00\' WHERE modifiedDt < \'2000-01-01\'');
$playlistTable
->changeColumn('createdDt', 'datetime', ['null' => true, 'default' => null])
->changeColumn('modifiedDt', 'datetime', ['null' => true, 'default' => null])
->addColumn('enableStat', 'string', ['null' => true])
->save();
}
$settingsTable = $this->table('setting');
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'PLAYLIST_STATS_ENABLED_DEFAULT\'')) {
$settingsTable
->insert([
[
'setting' => 'PLAYLIST_STATS_ENABLED_DEFAULT',
'value' => 'Inherit',
'userSee' => 1,
'userChange' => 1
]
])
->save();
}
}
}

View File

@@ -0,0 +1,43 @@
<?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 WidgetHistoryMigration
*/
class WidgetHistoryMigration extends AbstractMigration
{
/** @inheritDoc */
public function change()
{
$table = $this->table('widgethistory');
$table
->addColumn('layoutHistoryId', 'integer')
->addColumn('widgetId', 'integer')
->addColumn('mediaId', 'integer', ['null' => true])
->addColumn('type', 'string', ['limit' => 50])
->addColumn('name', 'string', ['limit' => 255, 'null' => true, 'default' => null])
->addForeignKey('layoutHistoryId', 'layouthistory', 'layoutHistoryId')
->save();
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 CreateStatTableMigration
*/
class CreateStatTableMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// If stat table exists then rename it
if ($this->hasTable('stat')) {
$this->table('stat')->rename('stat_archive')->save();
}
// Create stat table
$table = $this->table('stat', ['id' => 'statId']);
$table
->addColumn('type', 'string', ['limit' => 20])
->addColumn('statDate', 'integer')
->addColumn('scheduleId', 'integer')
->addColumn('displayId', 'integer')
->addColumn('campaignId', 'integer', ['default' => null, 'null' => true])
->addColumn('layoutId', 'integer', ['default' => null, 'null' => true])
->addColumn('mediaId', 'integer', ['default' => null, 'null' => true])
->addColumn('widgetId', 'integer', ['default' => null, 'null' => true])
->addColumn('start', 'integer')
->addColumn('end', 'integer')
->addColumn('tag', 'string', ['limit' => 254, 'default' => null, 'null' => true])
->addColumn('duration', 'integer')
->addColumn('count', 'integer')
->addIndex('statDate')
->addIndex(['displayId', 'end', 'type'])
->save();
}
}

View File

@@ -0,0 +1,47 @@
<?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 AddStatsMigrationTaskMigration
*/
class AddStatsMigrationTaskMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('task');
if (!$this->fetchRow('SELECT * FROM `task` WHERE name = \'Statistics Migration\'')) {
$table->insert([
[
'name' => 'Statistics Migration',
'class' => '\Xibo\XTR\StatsMigrationTask',
'options' => '{"killSwitch":"0","numberOfRecords":"5000","numberOfLoops":"10","pauseBetweenLoops":"1","optimiseOnComplete":"1"}',
'schedule' => '*/10 * * * * *',
'isActive' => '1',
'configFile' => '/tasks/stats-migration.task'
],
])->save();
}
}
}

View File

@@ -0,0 +1,38 @@
<?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 AddIsActiveReportScheduleMigration
*/
class AddIsActiveReportScheduleMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('reportschedule');
$table
->addColumn('isActive', 'integer', ['default' => 1, 'after' => 'userId'])
->save();
}
}

View File

@@ -0,0 +1,33 @@
<?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 NullableCommandValidationStringMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('lkcommanddisplayprofile');
$table->changeColumn('validationString', 'string', ['limit' => 1000, 'null' => true])->save();
}
}

View File

@@ -0,0 +1,35 @@
<?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 MissingDefaultValueMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('dataset');
$table->changeColumn('lastDataEdit', 'integer', ['default' => 0])
->changeColumn('lastClear', 'integer', ['default' => 0])
->save();
}
}

View File

@@ -0,0 +1,45 @@
<?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 AddScheduleReminderTaskMigration
*/
class AddScheduleReminderTaskMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('task');
$table->insert([
[
'name' => 'Schedule Reminder',
'class' => '\Xibo\XTR\ScheduleReminderTask',
'options' => '[]',
'schedule' => '*/5 * * * * *',
'isActive' => '1',
'configFile' => '/tasks/schedule-reminder.task'
],
])->save();
}
}

View File

@@ -0,0 +1,69 @@
<?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 DisplayProfileCommandLinkFixMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// query the database and look for duplicate entries
$duplicatesData = $this->query('SELECT commandId, displayProfileId FROM lkcommanddisplayprofile WHERE commandId IN ( SELECT commandId FROM lkcommanddisplayprofile GROUP BY commandId HAVING COUNT(*) > 1) ');
$rowsDuplicatesData = $duplicatesData->fetchAll(PDO::FETCH_ASSOC);
// only execute this code if any duplicates were found
if (count($rowsDuplicatesData) > 0) {
$duplicates = [];
// create new array with displayProfileId as the key
foreach ($rowsDuplicatesData as $row) {
$duplicates[$row['displayProfileId']][] = $row['commandId'];
}
// iterate through the arrays get unique commandIds, calculate the limit and execute Delete query.
foreach ($duplicates as $displayProfileId => $commandId) {
// commandId is an array, get the unique Ids from it
$uniqueCommandIds = array_unique($commandId);
// iterate through our array of uniqueCommandIds and calculate the LIMIT for our SQL Delete statement
foreach ($uniqueCommandIds as $uniqueCommandId) {
// create an array with commandId as the key and count of duplicate as value
$limits = array_count_values($commandId);
// Limits is an array with uniqueCommandId as the key and count of duplicate as value, we want to leave one record, hence we subtract 1
$limit = $limits[$uniqueCommandId] - 1;
// if we have any duplicates then run the delete statement, for each displayProfileId with uniqueCommandId and calculated limit per uniqueCommandId
if ($limit > 0) {
$this->execute('DELETE FROM lkcommanddisplayprofile WHERE commandId = ' . $uniqueCommandId . ' AND displayProfileId = ' . $displayProfileId . ' LIMIT ' . $limit);
}
}
}
}
// add the primary key for CMS upgrades, fresh CMS Installations will have it correctly added in installation migration.
if (!$this->fetchRow('SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME = \'lkcommanddisplayprofile\' AND CONSTRAINT_TYPE = \'PRIMARY KEY\' AND CONSTRAINT_SCHEMA = Database();')) {
$this->execute('ALTER TABLE lkcommanddisplayprofile ADD PRIMARY KEY (commandId, displayProfileId);');
}
}
}

View File

@@ -0,0 +1,38 @@
<?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 DatasetAddCustomHeadersColumnMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$dataSetTable = $this->table('dataset');
if (!$dataSetTable->hasColumn('customHeaders')) {
$dataSetTable
->addColumn('customHeaders', 'text', ['null' => true, 'default' => null, 'after' => 'password'])
->save();
}
}
}

View File

@@ -0,0 +1,39 @@
<?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 AddDoohUserTypeMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$userTypeTable = $this->table('usertype');
if (!$this->fetchRow('SELECT * FROM usertype WHERE `userType` = \'DOOH\'')) {
$userTypeTable->insert([
'userTypeId' => 4,
'userType' => 'DOOH'
])->save();
}
}
}

View File

@@ -0,0 +1,50 @@
<?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 CreateScheduleReminderTableMigration
*/
class CreateScheduleReminderTableMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Create table
$table = $this->table('schedulereminder', ['id' => 'scheduleReminderId']);
$table
->addColumn('eventId', 'integer')
->addColumn('value', 'integer')
->addColumn('type', 'integer')
->addColumn('option', 'integer')
->addColumn('reminderDt', 'integer')
->addColumn('lastReminderDt', 'integer')
->addColumn('isEmail', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
->addForeignKey('eventId', 'schedule', 'eventId')
->save();
}
}

View File

@@ -0,0 +1,39 @@
<?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 AddShowContentFromMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$userTable = $this->table('user');
if (!$userTable->hasColumn('showContentFrom')) {
$userTable
->addColumn('showContentFrom', 'integer', ['limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'default' => 1])
->save();
}
}
}

View File

@@ -0,0 +1,45 @@
<?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 AddImageProcessingTaskMigration
*/
class AddImageProcessingTaskMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
$table = $this->table('task');
$table->insert([
[
'name' => 'Image Processing',
'class' => '\Xibo\XTR\ImageProcessingTask',
'options' => '[]',
'schedule' => '*/5 * * * * *',
'isActive' => '1',
'configFile' => '/tasks/image-processing.task'
],
])->save();
}
}

View File

@@ -0,0 +1,58 @@
<?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 AddDefaultSettingResizeLimitResizeThresholdMigration
*/
class AddDefaultSettingResizeLimitResizeThresholdMigration extends AbstractMigration
{
/** @inheritdoc */
public function change()
{
// Add a setting allowing users to maximum image resizing to 1920
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'DEFAULT_RESIZE_LIMIT\'')) {
$this->table('setting')->insert([
[
'setting' => 'DEFAULT_RESIZE_LIMIT',
'value' => 6000,
'userSee' => 1,
'userChange' => 1
]
])->save();
}
// Add a setting allowing users set the limit to identify a large image dimensions
if (!$this->fetchRow('SELECT * FROM `setting` WHERE setting = \'DEFAULT_RESIZE_THRESHOLD\'')) {
$this->table('setting')->insert([
[
'setting' => 'DEFAULT_RESIZE_THRESHOLD',
'value' => 1920,
'userSee' => 1,
'userChange' => 1
]
])->save();
}
}
}

Some files were not shown because too many files have changed in this diff Show More