Skip to content

Commit

Permalink
Allow null for language and sales channel IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasGraml11 committed Nov 13, 2023
1 parent 7ec073c commit aa6d00b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Migration/Migration1699534500ConfigTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function update(Connection $connection): void
`id` binary(16) NOT NULL,
`configuration_key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`configuration_value` json NOT NULL,
`sales_channel_id` binary(16) NOT NULL,
`language_id` binary(16) NOT NULL,
`sales_channel_id` binary(16),
`language_id` binary(16),
`created_at` datetime(3) NOT NULL,
`updated_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
Expand Down Expand Up @@ -62,21 +62,21 @@ private function insertPreviousConfigurationIfExists(Connection $connection): vo

foreach ($configs as $config) {
$salesChannelId = $config['sales_channel_id'];
if (!$salesChannelId) {
$salesChannelId = $this->getDefaultSalesChannelId($connection);
}

$sql = 'SELECT LOWER(HEX(`language_id`)) AS `language_id` FROM `sales_channel` WHERE `id` = UNHEX(?)';
$languageId = $connection->fetchOne($sql, [$salesChannelId]);
$languageId = null;

if (!$languageId) {
continue;
if ($salesChannelId) {
$sql = 'SELECT LOWER(HEX(`language_id`)) AS `language_id` FROM `sales_channel` WHERE `id` = UNHEX(?)';
$languageId = $connection->fetchOne($sql, [$salesChannelId]);
}

$data = $config;
$data['id'] = Uuid::fromHexToBytes($config['id']);
$data['language_id'] = Uuid::fromHexToBytes($languageId);
$data['sales_channel_id'] = Uuid::fromHexToBytes($salesChannelId);
$data['language_id'] = $languageId
? Uuid::fromHexToBytes($languageId)
: null;
$data['sales_channel_id'] = $salesChannelId
? Uuid::fromHexToBytes($salesChannelId)
: null;
try {
$connection->insert('nosto_integration_config', $data);
} catch (Exception $exception) {
Expand Down

0 comments on commit aa6d00b

Please sign in to comment.