Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping Doctrine of superclass ProcessedMessage doesn't work #80

Open
Fofonew opened this issue Apr 4, 2024 · 4 comments
Open

Mapping Doctrine of superclass ProcessedMessage doesn't work #80

Fofonew opened this issue Apr 4, 2024 · 4 comments

Comments

@Fofonew
Copy link

Fofonew commented Apr 4, 2024

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
Copy link
Member

kbond commented Apr 9, 2024

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
Copy link
Author

Fofonew commented Apr 10, 2024

Yeah sure i did it, and it change nothing

@kbond
Copy link
Member

kbond commented Apr 10, 2024

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
Copy link
Contributor

Chris53897 commented Apr 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants