zenstruck / messenger-monitor-bundle

Batteries included UI to monitor your Messenger workers, transports, schedules, and messages.
MIT License
153 stars 16 forks source link

Mapping Doctrine of superclass ProcessedMessage doesn't work #80

Open Fofonew opened 6 months ago

Fofonew commented 6 months ago

When i do the command bin/console doctrine:mapping:info i see

bin/console doctrine:mapping:info
 Found 10 mapped entities:

 [OK]   App\Entity\AnonHistory
 [OK]   App\Entity\RequestHistory
 [OK]   App\Entity\SyncTrack
 [OK]   App\Entity\AnonHistoryAnonymizerStatus
 [OK]   App\Entity\Customer
 [OK]   App\Entity\ProcessedMessage
 [OK]   App\Entity\Activity
 [OK]   App\Entity\SyncType
 [OK]   App\Entity\ActivityType
 [OK]   Zenstruck\Messenger\Monitor\History\Model\ProcessedMessage

This is my entity file

<?php

// src/Entity/ProcessedMessage.php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Zenstruck\Messenger\Monitor\History\Model\ProcessedMessage as BaseProcessedMessage;

#[ORM\Entity(readOnly: true)]
#[ORM\Table('processed_messages')]
class ProcessedMessage extends BaseProcessedMessage
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    public function id(): ?int
    {
        return $this->id;
    }
}

but when i generate migration i got :

$this->addSql('CREATE SEQUENCE processed_messages_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE processed_messages (id INT NOT NULL, PRIMARY KEY(id))');
kbond commented 6 months ago

Hi @Fofonew, did you add the following config:

# config/packages/zenstruck_messenger_monitor.yaml

zenstruck_messenger_monitor:
    storage:
        orm:
            entity_class: App\Entity\ProcessedMessage

(and clear cache after?)

Fofonew commented 6 months ago

Yeah sure i did it, and it change nothing

kbond commented 6 months ago

Hmm, I can't create the issue locally, I see:

$this->addSql('CREATE SEQUENCE processed_messages_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE processed_messages (id INT NOT NULL, run_id INT NOT NULL, attempt SMALLINT NOT NULL, message_type VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, dispatched_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, received_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, finished_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, memory_usage INT NOT NULL, transport VARCHAR(255) NOT NULL, tags VARCHAR(255) DEFAULT NULL, failure_type VARCHAR(255) DEFAULT NULL, failure_message TEXT DEFAULT NULL, results JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN processed_messages.dispatched_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN processed_messages.received_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN processed_messages.finished_at IS \'(DC2Type:datetime_immutable)\'');

Could you create a simple reproducer?

Chris53897 commented 6 months ago

Did you rollback the incorrect migration and deleted the migration file? I think that @kbond is right, and is releated to caching. (i did had the same problem in the past).

Otherwise version of doctrine/orm version and database could be a useful info.