manufacturer-information/migration/data/Version20241028172608.php

78 lines
2.3 KiB
PHP
Raw Normal View History

2024-10-28 18:29:40 +01:00
<?php
2024-11-19 10:50:33 +01:00
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
2024-10-28 18:29:40 +01:00
declare(strict_types=1);
namespace D3\ManufacturerInformation\Migrations;
use Doctrine\DBAL\Schema\Schema;
2024-11-13 16:34:45 +01:00
use Doctrine\DBAL\Types\TextType;
2024-10-28 18:29:40 +01:00
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241028172608 extends AbstractMigration
{
2024-11-19 10:50:33 +01:00
public function getDescription(): string
2024-10-28 18:29:40 +01:00
{
2024-11-19 09:54:00 +01:00
return 'Adds multilang tables for the D3 manufacturer longdesc';
}
2024-11-19 10:50:33 +01:00
public function up(Schema $schema): void
2024-11-19 09:54:00 +01:00
{
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
$this->d3AddLongdescMultilangColumnsToOxmanufacturers($schema);
2024-10-28 18:29:40 +01:00
}
2024-11-19 10:50:33 +01:00
public function down(Schema $schema): void
{
}
2024-11-19 09:54:00 +01:00
/**
* @param Schema $schema
* @return void
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
2024-11-19 10:50:33 +01:00
public function d3AddLongdescMultilangColumnsToOxmanufacturers(Schema $schema)
{
2024-11-19 09:54:00 +01:00
$table = !$schema->hasTable('oxmanufacturers') ?
$schema->createTable('oxmanufacturers') :
$schema->getTable('oxmanufacturers');
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
// lang 1
if (!$table->hasColumn('D3DESCRIPTION_1')) {
$table->addColumn('D3DESCRIPTION_1', (new TextType())->getName())
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
->setNotnull(true);
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
// lang 2
if (!$table->hasColumn('D3DESCRIPTION_2')) {
$table->addColumn('D3DESCRIPTION_2', (new TextType())->getName())
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
->setNotnull(true);
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
// lang 3
if (!$table->hasColumn('D3DESCRIPTION_3')) {
$table->addColumn('D3DESCRIPTION_3', (new TextType())->getName())
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
->setNotnull(true);
}
}
2024-10-28 18:29:40 +01:00
}