Skip to content

Commit

Permalink
[Migrations] fix some migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed Aug 12, 2022
1 parent 904bfcf commit 009f876
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public function up(Schema $schema): void
$customerList = $customerRepository->getList();
$batchList = new DataObjectBatchListing($customerList, 100);

$doneUsers = [];

/**
* @var CustomerInterface $customer
*/
Expand All @@ -104,15 +106,19 @@ public function up(Schema $schema): void
continue;
}

$loginIdentifier = $this->container->getParameter('coreshop.customer.security.login_identifier') === 'username' && method_exists($customer, 'getUsername') ?
$customer->getUsername() :
$customer->getEmail();

if (in_array($loginIdentifier, $doneUsers, true)) {
continue;
}

/**
* @var UserInterface $user
*/
$user = $this->container->get('coreshop.factory.user')->createNew();
$user->setLoginIdentifier(
$this->container->getParameter('coreshop.customer.security.login_identifier') === 'username' && method_exists($customer, 'getUsername') ?
$customer->getUsername() :
$customer->getEmail()
);
$user->setLoginIdentifier($loginIdentifier );
$user->setPassword($customer->getPassword());
$user->setParent(Service::createFolderByPath(sprintf(
'/%s/%s',
Expand All @@ -123,6 +129,8 @@ public function up(Schema $schema): void
$user->setKey($customer->getEmail());
$user->save();

$doneUsers[] = $loginIdentifier;

$customer->setUser($user);
$customer->save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ public function up(Schema $schema): void

$classUpdater = new ClassUpdate($class);

$classUpdater->setProperty('generateTypeDeclarations', true);
if (!$classUpdater->getProperty('generateTypeDeclarations')) {
$classUpdater->setProperty('generateTypeDeclarations', true);
}

foreach ($fields as $field => $config) {
$classUpdater->replaceFieldProperties($field, $config);
if ($classUpdater->hasField($field)) {
$classUpdater->replaceFieldProperties($field, $config);
}
}

$classUpdater->save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ public function up(Schema $schema): void

$fields = [
[
'fieldtype' => 'coreShopMoney',
'fieldtype' => 'numeric',
'fieldtype' => 'numeric',
'width' => '',
'defaultValue' => null,
'phpdocType' => 'int',
'minValue' => null,
'maxValue' => null,
'defaultValue' => NULL,
'integer' => true,
'unsigned' => false,
'minValue' => NULL,
'maxValue' => NULL,
'unique' => false,
'decimalSize' => NULL,
'decimalPrecision' => NULL,
'name' => 'convertedPaymentTotal',
'title' => 'coreshop.order.converted_payment_total',
'tooltip' => '',
Expand All @@ -48,7 +53,7 @@ public function up(Schema $schema): void
'index' => false,
'locked' => false,
'style' => '',
'permissions' => null,
'permissions' => NULL,
'datatype' => 'data',
'relationType' => false,
'invisible' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

declare(strict_types=1);

namespace C0oreShop\Bundle\CoreBundle\Migrations;
namespace CoreShop\Bundle\CoreBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()

abstract public function save(): bool;

public function getProperty(string $property): array
public function getProperty(string $property): mixed
{
return $this->jsonDefinition[$property];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface ClassUpdateInterface
{
public function save(): bool;

public function getProperty(string $property): array;
public function getProperty(string $property): mixed;

public function setProperty(string $property, $value): void;

Expand Down

0 comments on commit 009f876

Please sign in to comment.