First upload

This commit is contained in:
Nikolai Fesenko
2025-02-02 13:37:56 +01:00
commit 8d227c9191
3281 changed files with 362319 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Change oxtplblocks oxmodule field max length to 100
* as it is in oxconfig and oxconfigdisplay tables
*/
class Version20170718124421 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql("ALTER TABLE `oxtplblocks`
CHANGE `OXMODULE` `OXMODULE` varchar(100)
character set latin1 collate latin1_general_ci NOT NULL
COMMENT 'Module, which uses this template';");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
}
public function isTransactional(): bool
{
return false;
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Update from v6.0.0-rc.2 to v6.0.0-rc.3
*/
class Version20171018144650 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
// All tables should have the same default character set and collation
$this->addSql("ALTER table `oxinvitations` COLLATE utf8_general_ci;");
$this->addSql("ALTER table `oxobject2action` COLLATE utf8_general_ci;");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
}
public function isTransactional(): bool
{
return false;
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/** Empty migration file to suppress warning */
class Version20180214152228 extends AbstractMigration
{
public function up(Schema $schema): void
{
}
public function down(Schema $schema): void
{
}
public function isTransactional(): bool
{
return false;
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* change oxconfig::oxvarvalue type to mediumblob for large module lists
*/
class Version20180228160418 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->skipIf(true, 'Migration can no longer be applied.');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
}
public function isTransactional(): bool
{
return false;
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\ConfigFile;
use OxidEsales\Facts\Facts;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180703135728 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$facts = new Facts();
$configFile = new ConfigFile($facts->getSourcePath() . '/config.inc.php');
$configKey = is_null($configFile->getVar('sConfigKey')) ? Config::DEFAULT_CONFIG_KEY : $configFile->getVar('sConfigKey');
$varName = 'contactFormRequiredFields';
$varType = 'arr';
$rawValue = serialize(['email']);
$query = "INSERT INTO `oxconfig`
(
`OXID`,
`OXSHOPID`,
`OXVARNAME`,
`OXVARTYPE`,
`OXVARVALUE`
)
SELECT
REPLACE(UUID( ) , '-', '' ),
`OXID`,
?,
?,
?
FROM `oxshops`
WHERE NOT EXISTS (
SELECT `OXVARNAME`
FROM `oxconfig`
WHERE `OXVARNAME` = ?
AND `oxconfig`.OXSHOPID = `oxshops`.OXID
)";
$this->addSql(
$query,
[$varName, $varType, $rawValue, $varName]
);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
public function isTransactional(): bool
{
return false;
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\ConfigFile;
use OxidEsales\Facts\Facts;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180928072235 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$configSettingName = 'includeProductReviewLinksInEmail';
$configSettingType = 'bool';
$configSettingValue = '1';
$query = "INSERT INTO `oxconfig`
(
`OXID`,
`OXSHOPID`,
`OXVARNAME`,
`OXVARTYPE`,
`OXVARVALUE`
)
SELECT
REPLACE(UUID() , '-', '' ),
`OXID`,
?,
?,
?
FROM `oxshops`
WHERE NOT EXISTS (
SELECT `OXVARNAME`
FROM `oxconfig`
WHERE `OXVARNAME` = ?
AND `oxconfig`.OXSHOPID = `oxshops`.OXID
)";
$this->addSql(
$query,
[
$configSettingName,
$configSettingType,
$configSettingValue,
$configSettingName,
]
);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
/**
* @return string
*/
private function getConfigEncryptionKey(): string
{
$facts = new Facts();
$configFile = new ConfigFile($facts->getSourcePath() . '/config.inc.php');
return $configFile->getVar('sConfigKey') ?? Config::DEFAULT_CONFIG_KEY;
}
public function isTransactional(): bool
{
return false;
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20201029110624 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$table = $schema->getTable('oxuser');
$table->addIndex(['oxrights'], 'OXRIGHTS');
}
public function down(Schema $schema): void
{
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$table = $schema->getTable('oxuser');
$table->dropIndex('oxrights');
}
public function isTransactional(): bool
{
return false;
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\Migrations\AbstractMigration;
use OxidEsales\EshopCommunity\Core\Config;
final class Version20230322213324 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->skipIf($this->connection->getDatabasePlatform() instanceof MySQL80Platform, 'Config values can\'t decoded on MySQL 8');
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$table = $schema->getTable('oxconfig');
$column = $table->getColumn('oxvarvalue');
$this->skipIf(!$column->getType() instanceof BlobType, 'Config values are already decoded');
$this->addSql('ALTER TABLE oxconfig ADD COLUMN `OXVARVALUE_UNENC` text;');
$this->addSql("UPDATE oxconfig SET `OXVARVALUE_UNENC` = DECODE(OXVARVALUE, '".Config::DEFAULT_CONFIG_KEY."') WHERE 1;");
$this->addSql('ALTER TABLE oxconfig MODIFY COLUMN `OXVARVALUE` text;');
$this->addSql("UPDATE oxconfig SET `OXVARVALUE` = `OXVARVALUE_UNENC` WHERE 1;");
$this->addSql('ALTER TABLE oxconfig DROP COLUMN `OXVARVALUE_UNENC`;');
}
public function down(Schema $schema): void
{
$this->skipIf($this->connection->getDatabasePlatform() instanceof MySQL80Platform, 'Config values can\'t encoded on MySQL 8');
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$table = $schema->getTable('oxconfig');
$column = $table->getColumn('oxvarvalue');
$this->skipIf($column->getType() instanceof BlobType, 'Config values are already encoded');
$this->addSql( 'ALTER TABLE oxconfig ADD COLUMN `OXVARVALUE_ENC` text;' );
$this->addSql( "UPDATE oxconfig SET `OXVARVALUE_ENC` = ENCODE(OXVARVALUE, '" . Config::DEFAULT_CONFIG_KEY . "') WHERE 1;" );
$this->addSql( 'ALTER TABLE oxconfig MODIFY COLUMN `OXVARVALUE` mediumblob;' );
$this->addSql( "UPDATE oxconfig SET `OXVARVALUE` = `OXVARVALUE_ENC` WHERE 1;" );
$this->addSql( 'ALTER TABLE oxconfig DROP COLUMN `OXVARVALUE_ENC`;' );
}
public function isTransactional(): bool
{
return true;
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\Migrations\AbstractMigration;
use OxidEsales\EshopCommunity\Core\Config;
final class Version20230322214524 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->skipIf($this->connection->getDatabasePlatform() instanceof MySQL80Platform, 'Userpayment values can\'t decoded on MySQL 8');
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$table = $schema->getTable('oxuserpayments');
$column = $table->getColumn('oxvalue');
$this->skipIf(!$column->getType() instanceof BlobType, 'Userpayment values are already decoded');
$this->addSql('ALTER TABLE oxuserpayments ADD COLUMN `OXVALUE_UNENC` text;');
$this->addSql("UPDATE oxuserpayments SET `OXVALUE_UNENC` = DECODE(OXVALUE, '".Config::DEFAULT_CONFIG_KEY."') WHERE 1;");
$this->addSql('ALTER TABLE oxuserpayments MODIFY COLUMN `OXVALUE` text;');
$this->addSql("UPDATE oxuserpayments SET `OXVALUE` = `OXVALUE_UNENC` WHERE 1;");
$this->addSql('ALTER TABLE oxuserpayments DROP COLUMN `OXVALUE_UNENC`;');
}
public function down(Schema $schema): void
{
$this->skipIf($this->connection->getDatabasePlatform() instanceof MySQL80Platform, 'Userpayment values can\'t encoded on MySQL 8');
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$table = $schema->getTable('oxuserpayments');
$column = $table->getColumn('oxvalue');
$this->skipIf($column->getType() instanceof BlobType, 'Userpayment values are already encoded');
$this->addSql('ALTER TABLE oxuserpayments ADD COLUMN `OXVALUE_ENC` text;');
$this->addSql("UPDATE oxuserpayments SET `OXVALUE_ENC` = ENCODE(OXVALUE, '".Config::DEFAULT_CONFIG_KEY."') WHERE 1;");
$this->addSql('ALTER TABLE oxuserpayments MODIFY COLUMN `OXVALUE` blob;');
$this->addSql("UPDATE oxuserpayments SET `OXVALUE` = `OXVALUE_ENC` WHERE 1;");
$this->addSql('ALTER TABLE oxuserpayments DROP COLUMN `OXVALUE_ENC`;');
}
public function isTransactional(): bool
{
return true;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\Migrations\AbstractMigration;
final class Version20230405094126 extends AbstractMigration
{
protected string $columnname = 'OXISPLAIN';
public function getDescription() : string
{
return 'add plain option to content elements';
}
public function up(Schema $schema) : void
{
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$table = $schema->getTable('oxcontents');
$this->skipIf( $table->hasColumn($this->columnname), 'column already exists');
$table->addColumn($this->columnname, (new IntegerType())->getName())
->setLength(1)
->setNotnull(true)
->setDefault(0);
}
public function down(Schema $schema) : void
{
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$table = $schema->getTable('oxcontents');
$this->skipIf( !$table->hasColumn($this->columnname), 'column doesn\'t exist');
$table->dropColumn($this->columnname);
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 OXID eSales AG (https://www.oxid-esales.com)
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230405121448 extends AbstractMigration
{
public function getDescription() : string
{
return 'set affected content elements to plain';
}
public function up(Schema $schema) : void
{
$this->addSql(
'UPDATE oxcontents SET OXISPLAIN = ? WHERE oxloadid LIKE "%plain%"',
[1]
);
}
public function down( Schema $schema ): void {}
}

View File

@@ -0,0 +1,181 @@
<?php
/**
* This file is part of O3-Shop.
*
* O3-Shop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* O3-Shop 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
*
* @copyright Copyright (c) 2022 O3-Shop (https://www.o3-shop.com)
* @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3)
*/
declare(strict_types=1);
namespace OxidEsales\EshopCommunity\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\DateTimeType;
use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\StringType;
use Doctrine\Migrations\AbstractMigration;
use OxidEsales\EshopCommunity\Application\Model\RightsRolesElement;
final class Version20230730131836 extends AbstractMigration
{
public function getDescription() : string
{
return 'add admin navigation roles tables';
}
public function up(Schema $schema) : void
{
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$this->rightsRolesTable($schema);
$this->rightsRolesElementsTable($schema);
$this->object2roleTable($schema);
}
public function down( Schema $schema ): void {}
public function rightsRolesTable(Schema $schema): void
{
$rightsRolesTable = $schema->hasTable('o3rightsroles') ?
$schema->getTable('o3rightsroles') :
$schema->createTable('o3rightsroles');
if (!$rightsRolesTable->hasColumn('OXID')) {
$rightsRolesTable->addColumn('OXID', (new StringType())->getName())
->setLength(32)
->setFixed(true)
->setNotnull(true);
}
if (!$rightsRolesTable->hasColumn('OXSHOPID')) {
$rightsRolesTable->addColumn('OXSHOPID', (new IntegerType())->getName())
->setLength(11)
->setNotnull(true);
}
if (!$rightsRolesTable->hasColumn('ACTIVE')) {
$rightsRolesTable->addColumn('ACTIVE', (new IntegerType())->getName())
->setLength(1)
->setFixed(true)
->setDefault(1)
->setNotnull(true);
}
if (!$rightsRolesTable->hasColumn('TITLE')) {
$rightsRolesTable->addColumn('TITLE', (new StringType())->getName())
->setLength(255)
->setFixed(false)
->setNotnull(true);
}
for ($lang = 1; $lang <= 3; $lang++) {
if ( ! $rightsRolesTable->hasColumn( 'TITLE_'.$lang ) ) {
$rightsRolesTable->addColumn( 'TITLE_'.$lang, ( new StringType() )->getName() )
->setLength( 255 )
->setFixed( false )
->setNotnull( true );
}
}
if (!$rightsRolesTable->hasColumn('OXTIMESTAMP')) {
$rightsRolesTable->addColumn('OXTIMESTAMP', (new DateTimeType())->getName())
->setNotnull(true)
->setDefault('CURRENT_TIMESTAMP');
}
$rightsRolesTable->hasPrimaryKey() ?: $rightsRolesTable->setPrimaryKey(['OXID', 'OXID']);
}
public function rightsRolesElementsTable(Schema $schema): void
{
$rightsRolesElementsTable = $schema->hasTable('o3rightsroleselements') ?
$schema->getTable('o3rightsroleselements') :
$schema->createTable('o3rightsroleselements');
if (!$rightsRolesElementsTable->hasColumn('OXID')) {
$rightsRolesElementsTable->addColumn('OXID', (new StringType())->getName())
->setLength(32)
->setFixed(true)
->setNotnull(true);
}
if (!$rightsRolesElementsTable->hasColumn('ELEMENTID')) {
$rightsRolesElementsTable->addColumn('ELEMENTID', (new StringType())->getName())
->setLength(32)
->setFixed(true)
->setNotnull(true);
}
if (!$rightsRolesElementsTable->hasColumn('OBJECTID')) {
$rightsRolesElementsTable->addColumn('OBJECTID', (new StringType())->getName())
->setLength(32)
->setFixed(true)
->setNotnull(true)
->setComment('role or user id');
}
if (!$rightsRolesElementsTable->hasColumn('TYPE')) {
$rightsRolesElementsTable->addColumn('TYPE', (new IntegerType())->getName())
->setLength(1)
->setFixed(true)
->setNotnull(true)
->setDefault(RightsRolesElement::TYPE_EDITABLE)
->setComment('right type: 0 = hidden, 1 = readonly, 2 = editable');
}
if (!$rightsRolesElementsTable->hasColumn('OXTIMESTAMP')) {
$rightsRolesElementsTable->addColumn('OXTIMESTAMP', (new DateTimeType())->getName())
->setNotnull(true)
->setDefault('CURRENT_TIMESTAMP');
}
$rightsRolesElementsTable->hasPrimaryKey() ?: $rightsRolesElementsTable->setPrimaryKey(['OXID', 'OXID']);
$rightsRolesElementsTable->hasIndex('OBJECT_IDX') ?:
$rightsRolesElementsTable->addIndex(['OBJECTID'], 'OBJECT_IDX');
$rightsRolesElementsTable->hasIndex('ROLETYPE_IDX') ?:
$rightsRolesElementsTable->addIndex(['OBJECTID', 'TYPE'], 'ROLETYPE_IDX');
}
public function object2roleTable(Schema $schema)
{
$object2RoleTable = $schema->hasTable('o3object2role') ?
$schema->getTable('o3object2role') :
$schema->createTable('o3object2role');
if (!$object2RoleTable->hasColumn('OXID')) {
$object2RoleTable->addColumn('OXID', (new StringType())->getName())
->setLength(32)
->setFixed(true)
->setNotnull(true);
}
if (!$object2RoleTable->hasColumn('OBJECTID')) {
$object2RoleTable->addColumn('OBJECTID', (new StringType())->getName())
->setLength(32)
->setFixed(true)
->setNotnull(true);
}
if (!$object2RoleTable->hasColumn('ROLEID')) {
$object2RoleTable->addColumn('ROLEID', (new StringType())->getName())
->setLength(32)
->setFixed(true)
->setNotnull(true);
}
if (!$object2RoleTable->hasColumn('OXTIMESTAMP')) {
$object2RoleTable->addColumn('OXTIMESTAMP', (new DateTimeType())->getName())
->setNotnull(true)
->setDefault('CURRENT_TIMESTAMP');
}
$object2RoleTable->hasPrimaryKey() ?: $object2RoleTable->setPrimaryKey(['OXID', 'OXID']);
$object2RoleTable->hasIndex('ROLEOBJECT_IDX') ?:
$object2RoleTable->addUniqueIndex( [ 'ROLEID', 'OBJECTID' ], 'ROLEOBJECT_IDX' );
}
}