*/ namespace oat\taoProctoring\scripts\update\v8_12_0; use oat\oatbox\extension\AbstractAction; use oat\taoProctoring\model\deliveryLog\implementation\RdsDeliveryLogService; class AddIndexesToDeliveryLogTable extends AbstractAction { public function __invoke($params) { $deliveryLogService = $this->getServiceLocator()->get(RdsDeliveryLogService::SERVICE_ID); $persistenceManager = $this->getServiceLocator()->get(\common_persistence_Manager::SERVICE_ID); $persistence = $persistenceManager->getPersistenceById($deliveryLogService->getOption(RdsDeliveryLogService::OPTION_PERSISTENCE)); $schemaManager = $persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; $tableData = $schema->getTable(RdsDeliveryLogService::TABLE_NAME); $tableData->addIndex( [RdsDeliveryLogService::EVENT_ID], 'IDX_' . RdsDeliveryLogService::TABLE_NAME . '_' . RdsDeliveryLogService::EVENT_ID ); $tableData->addIndex( [RdsDeliveryLogService::CREATED_AT], 'IDX_' . RdsDeliveryLogService::TABLE_NAME . '_' . RdsDeliveryLogService::CREATED_AT ); $tableData->addIndex( [RdsDeliveryLogService::CREATED_BY], 'IDX_' . RdsDeliveryLogService::TABLE_NAME . '_' . RdsDeliveryLogService::CREATED_BY ); $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } } }