Skip to content

Commit

Permalink
Fixed migrations issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuba Płaskonka committed Oct 8, 2021
1 parent 59b295b commit bdc0187
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/ScheduledExportBundle/DivanteScheduledExportBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Divante\ScheduledExportBundle;

use Divante\ScheduledExportBundle\Migrations\Installer;
use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
use Pimcore\Extension\Bundle\Traits\PackageVersionTrait;

Expand Down
8 changes: 4 additions & 4 deletions src/ScheduledExportBundle/Export/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ public function getExportRegistry() : ScheduledExportRegistry
Folder::getByPath($this->objectsFolder)->getId() ?? 0
);

$exportRegistry = ScheduledExportRegistry::getByGridConfigId($adaptedGridConfigId);

if (!$exportRegistry) {
try {
$exportRegistry = ScheduledExportRegistry::getByGridConfigId($adaptedGridConfigId);
} catch (Exception $exception) {
$exportRegistry = new ScheduledExportRegistry();
$exportRegistry->setGridConfigId($adaptedGridConfigId);
$exportRegistry->save();
}

return $exportRegistry;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Divante\ScheduledExportBundle;
namespace Divante\ScheduledExportBundle\Migrations;

use Divante\ScheduledExportBundle\Model\ScheduledExportRegistry;
use Divante\ScheduledExportBundle\Model\ScheduledExportRegistry\Dao;
Expand Down Expand Up @@ -43,21 +43,11 @@ private function installDatabase(): void
'CREATE TABLE IF NOT EXISTS `' . Dao::TABLE_NAME . '` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`gridConfigId` varchar(255) NOT NULL,
`data` varchar(255) NOT NULL,
`data` varchar(255),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;'
);

//insert permission
$key = Dao::TABLE_NAME;
$permission = new Definition();
$permission->setKey($key);

$res = new DefinitionDao();
$res->configure(\Pimcore\Db::get());
$res->setModel($permission);
$res->save();

$list = new Listing();
$settings = $list->getSettings();

Expand All @@ -68,7 +58,7 @@ private function installDatabase(): void

$adaptedGridConfigId = sprintf('%s_%s', $name[0], $name[1]);

$exportRegistry = new ScheduledExportRegistry($adaptedGridConfigId, $item->getData());
$exportRegistry = new ScheduledExportRegistry($adaptedGridConfigId, (string) $item->getData());
$exportRegistry->save();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ScheduledExportRegistry extends AbstractModel

public function __construct(string $gridConfigId = null, $data = null)
{
if (!empty($gridConfigId) && !empty($data)) {
if (!empty($gridConfigId)) {
$this->setGridConfigId($gridConfigId);
$this->setData($data);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ScheduledExportBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
tags:
- { name: 'process_manager.process', type: 'scheduledexport', form-type: Divante\ScheduledExportBundle\Form\Type\ProcessManager\ScheduledExportType }

Divante\ScheduledExportBundle\Installer:
Divante\ScheduledExportBundle\Migrations\Installer:
public: true
arguments:
$bundle: "@=service('kernel').getBundle('DivanteScheduledExportBundle')"

0 comments on commit bdc0187

Please sign in to comment.