Skip to content

Commit 6752627

Browse files
committed
fix migrate cron service
1 parent c378f41 commit 6752627

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Model/Migrate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function migrateQueue(): void
6666
// Start migration
6767
$this->migrateDb->updateState($typeIds, 'running');
6868

69+
// Todo: handle batch management to avoid out of memory on large dataset with tons of files
6970
$documentCollection = $this->createDocumentCollection($typeIds);
7071
$docTypeCollection = $this->createDocTypeCollection($typeIds);
7172

@@ -99,7 +100,7 @@ private function createDocTypeCollection(array $typeIds): DocTypeCollection
99100
{
100101
$docTypeCollection = $this->docTypeCollectionFactory->create();
101102
$docTypeCollection->addFieldToSelect(['entity_id', 'file_dest_path', 'sub_path_length', 'is_restricted']);
102-
$docTypeCollection->addFieldToFilter('type_id', ['in' => $typeIds]);
103+
$docTypeCollection->addFieldToFilter('entity_id', ['in' => $typeIds]);
103104

104105
return $docTypeCollection;
105106
}

etc/crontab.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
99
<group id="opengento_document">
1010
<job name="opengento_document_type_restrict_migrate" instance="Opengento\DocumentRestrict\Cron\Migrate" method="execute">
11-
<config_path>opengento_document/migrate/schedule_migrate</config_path>
11+
<config_path>opengento_document/migrate/migrate_schedule</config_path>
1212
</job>
1313
<job name="opengento_document_type_restrict_migrate_rotate" instance="Opengento\DocumentRestrict\Cron\Rotate" method="execute">
14-
<config_path>opengento_document/migrate/schedule_rotate</config_path>
14+
<config_path>opengento_document/migrate/rotate_schedule</config_path>
1515
</job>
1616
</group>
1717
</config>

etc/db_schema.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
<constraint xsi:type="primary" referenceId="PRIMARY">
4141
<column name="entity_id"/>
4242
</constraint>
43-
<constraint xsi:type="foreign" referenceId="OPENGENTO_DOCUMENT_RESTRICT_TYPE_ID_OPENGENTO_DOCUMENT_TYPE_ENTITY_ID" table="opengento_document_type_restrict_migrate" column="type_id" referenceTable="opengento_document_type" referenceColumn="entity_id" onDelete="CASCADE"/>
44-
<constraint xsi:type="unique" referenceId="OPENGENTO_DOCUMENT_TYPE_RESTRICT_TYPE_ID">
43+
<constraint xsi:type="foreign" referenceId="OPENGENTO_DOCUMENT_RESTRICT_MIGRATE_TYPE_ID_OPENGENTO_DOCUMENT_TYPE_ENTITY_ID" table="opengento_document_type_restrict_migrate" column="type_id" referenceTable="opengento_document_type" referenceColumn="entity_id" onDelete="CASCADE"/>
44+
<index referenceId="OPENGENTO_DOCUMENT_TYPE_RESTRICT_MIGRATE_TYPE_ID" indexType="btree">
4545
<column name="type_id"/>
46-
</constraint>
46+
</index>
4747
</table>
4848
<!-- opengento_document_type_restrict_customer -->
4949
<!-- new relations in (document type or document) -->

0 commit comments

Comments
 (0)