Skip to content

Create my loyalty program

I try to create my loyalty program, use this module https://github.com/brjupo/Magento_2.4_E.E._RewardPointsGrid

I copied the code, but I get an error after “bin/magento setup:upgrade”
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘magento.magento_reward’ doesn’t exist

why i dont have a table magento_reward?
How to finish a module? What is the best way to make a table? I will be grateful for help

 <?php

namespace BrjupoRewardPointsReportSetupPatchSchema;

use MagentoFrameworkSetupPatchSchemaPatchInterface;
use MagentoFrameworkSetupSchemaSetupInterface;


class CreateRewardPointsView implements SchemaPatchInterface
{

private $schemaSetup;


public function __construct(
SchemaSetupInterface $schemaSetup
){
$this->schemaSetup = $schemaSetup;
}


public function getAliases()
{
  return [];
}


public function apply()
{
$this->schemaSetup->startSetup();

$sql = "DROP VIEW IF EXISTS rewardpoints_report;";
$this->schemaSetup->getConnection()->query($sql);

$sql = "CREATE SQL SECURITY INVOKER VIEW rewardpoints_report AS
        (
        SELECT 
          reward_points_delta_expiration.history_id,
          customer_entity.firstname,
          customer_entity.lastname,
          customer_entity.email,
          reward_points_delta_expiration.points_delta,
          reward_points_delta_expiration.expired_at_static
        FROM
          customer_entity
        INNER JOIN
          ( SELECT 
              magento_reward_history.history_id,
              magento_reward.customer_id,
              magento_reward_history.points_delta,
              magento_reward_history.expired_at_static
            FROM
              magento_reward
            INNER JOIN magento_reward_history 
              ON magento_reward.reward_id = magento_reward_history.reward_id
          ) AS reward_points_delta_expiration 
        ON customer_entity.entity_id = reward_points_delta_expiration.customer_id
        ORDER BY reward_points_delta_expiration.history_id DESC
        );";

$this->schemaSetup->getConnection()->query($sql);
$this->schemaSetup->endSetup();


 return $this;
}
public static function getDependencies()
{
  return [];
}
}