Skip to content

[Messenger] [Doctrine] Cannot generate migration, if no entity nor mapping infos available #39928

@OskarStark

Description

@OskarStark

Symfony version(s) affected: 5.1.10

PHP version:

PHP 8.0.1 (cli) (built: Jan  8 2021 02:39:34) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.1, Copyright (c), by Zend Technologies

Installed packages:

composer/package-versions-deprecated 1.11.99.1 Composer plugin that provides efficient querying for installed package versions (no runtime IO)
composer/semver                      3.2.4     Semver library that offers utilities, version constraint parsing and validation.
composer/xdebug-handler              1.4.5     Restarts a process without Xdebug.
dama/doctrine-test-bundle            v6.5.0    Symfony bundle to isolate doctrine database tests and improve test performance
datana-gmbh/php-cs-fixer-config      1.1.0     Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.
doctrine/annotations                 1.11.1    Docblock Annotations Parser
doctrine/cache                       1.10.2    PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and ...
doctrine/collections                 1.6.7     PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                      3.1.0     PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflec...
doctrine/dbal                        2.12.1    Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/doctrine-bundle             2.2.2     Symfony DoctrineBundle
doctrine/doctrine-migrations-bundle  3.0.2     Symfony DoctrineMigrationsBundle
doctrine/event-manager               1.1.1     The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                   2.0.3     PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of ...
doctrine/instantiator                1.4.0     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       1.2.1     PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                  3.0.2     PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database ...
doctrine/orm                         2.8.1     Object-Relational-Mapper for PHP
doctrine/persistence                 2.1.0     The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/sql-formatter               1.1.1     a PHP SQL highlighting library
egulias/email-validator              2.1.25    A library for validating emails against several RFCs
ergebnis/classy                      1.1.0     Provides a finder for classy constructs (classes, interfaces, and traits).
ergebnis/clock                       2.2.0     Provides a simple abstraction of a clock.
ergebnis/composer-normalize          2.13.2    Provides a composer plugin for normalizing composer.json.
ergebnis/factory-bot                 0.4.0     Provides a fixture factory for doctrine/orm entities.
ergebnis/json-normalizer             1.0.2     Provides generic and vendor-specific normalizers for normalizing JSON documents.
ergebnis/json-printer                3.1.1     Provides a JSON printer, allowing for flexible indentation.
ergebnis/test-util                   1.4.0     Provides a helper trait and generic data providers for tests.
fakerphp/faker                       v1.13.0   Faker is a PHP library that generates fake data for you.
friendsofphp/php-cs-fixer            v2.18.0   A tool to automatically fix PHP code style
friendsofphp/proxy-manager-lts       v1.0.2    Adding support for a wider range of PHP versions to ocramius/proxy-manager
justinrainbow/json-schema            5.2.10    A library to validate a json schema.
laminas/laminas-code                 4.0.0     Extensions to the PHP Reflection API, static code scanning, and code generation
laminas/laminas-eventmanager         3.3.0     Trigger and listen to events within a PHP application
laminas/laminas-zendframework-bridge 1.1.1     Alias legacy ZF class names to Laminas Project equivalents.
localheinz/diff                      1.1.1     Fork of sebastian/diff for use with ergebnis/composer-normalize
monolog/monolog                      2.2.0     Sends your logs to files, sockets, inboxes, databases and various web services
myclabs/deep-copy                    1.10.2    Create deep copies (clones) of your objects
nikic/php-parser                     v4.10.4   A PHP parser written in PHP
phar-io/manifest                     2.0.1     Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                      3.0.4     Library for handling version information and constraints
php-cs-fixer/diff                    v1.3.1    sebastian/diff v2 backport support for PHP5.6
phpdocumentor/reflection-common      2.2.0     Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock    5.2.2     With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a Doc...
phpdocumentor/type-resolver          1.4.0     A PSR-5 based resolver of Class names, Types and Structural Element Names
...
psr/cache                            1.0.1     Common interface for caching libraries
psr/container                        1.0.0     Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                 1.0.0     Standard interfaces for event handling.
psr/link                             1.0.0     Common interfaces for HTTP links
psr/log                              1.1.3     Common interface for logging libraries
...
sensio/framework-extra-bundle        v5.6.1    This bundle provides a way to configure your controllers with annotations
symfony/amqp-messenger               v5.2.1    Symfony AMQP extension Messenger Bridge
symfony/asset                        v5.2.1    Symfony Asset Component
symfony/browser-kit                  v5.2.1    Symfony BrowserKit Component
symfony/cache                        v5.2.1    Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts              v2.2.0    Generic abstractions related to caching
symfony/config                       v5.2.1    Symfony Config Component
symfony/console                      v5.2.1    Symfony Console Component
symfony/css-selector                 v5.2.1    Symfony CssSelector Component
symfony/debug-bundle                 v5.2.1    Symfony DebugBundle
symfony/dependency-injection         v5.2.1    Symfony DependencyInjection Component
symfony/deprecation-contracts        v2.2.0    A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge              v5.2.1    Symfony Doctrine Bridge
symfony/doctrine-messenger           v5.2.1    Symfony Doctrine Messenger Bridge
symfony/dom-crawler                  v5.2.1    Symfony DomCrawler Component
symfony/dotenv                       v5.2.1    Registers environment variables from a .env file
symfony/error-handler                v5.2.1    Symfony ErrorHandler Component
symfony/event-dispatcher             v5.2.1    Symfony EventDispatcher Component
symfony/event-dispatcher-contracts   v2.2.0    Generic abstractions related to dispatching event
symfony/expression-language          v5.2.1    Symfony ExpressionLanguage Component
symfony/filesystem                   v5.2.1    Symfony Filesystem Component
symfony/finder                       v5.2.1    Symfony Finder Component
symfony/flex                         v1.11.0   Composer plugin for Symfony
symfony/form                         v5.2.1    Symfony Form Component
symfony/framework-bundle             v5.2.1    Symfony FrameworkBundle
symfony/http-client                  v5.2.1    Symfony HttpClient component
symfony/http-client-contracts        v2.3.1    Generic abstractions related to HTTP clients
symfony/http-foundation              v5.2.1    Symfony HttpFoundation Component
symfony/http-kernel                  v5.2.1    Symfony HttpKernel Component
symfony/intl                         v5.2.1    A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/mailer                       v5.2.1    Symfony Mailer Component
symfony/maker-bundle                 v1.28.0   Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/messenger                    v5.2.1    Symfony Messenger Component
symfony/mime                         v5.2.1    A library to manipulate MIME messages
symfony/monolog-bridge               v5.2.1    Symfony Monolog Bridge
symfony/monolog-bundle               v3.6.0    Symfony MonologBundle
symfony/notifier                     v5.2.1    A library to notify messages
symfony/options-resolver             v5.2.1    Symfony OptionsResolver Component
symfony/phpunit-bridge               v5.2.1    Symfony PHPUnit Bridge
symfony/polyfill-intl-grapheme       v1.22.0   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu            v1.20.0   Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn            v1.22.0   Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer     v1.22.0   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring            v1.22.0   Symfony polyfill for the Mbstring extension
symfony/polyfill-php70               v1.20.0   Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php73               v1.22.0   Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80               v1.22.0   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/process                      v5.2.1    Symfony Process Component
symfony/property-access              v5.2.1    Symfony PropertyAccess Component
symfony/property-info                v5.2.1    Symfony Property Info Component
symfony/proxy-manager-bridge         v5.2.1    Symfony ProxyManager Bridge
symfony/redis-messenger              v5.2.1    Symfony Redis extension Messenger Bridge
symfony/routing                      v5.2.1    Symfony Routing Component
symfony/security-bundle              v5.2.1    Symfony SecurityBundle
symfony/security-core                v5.2.1    Symfony Security Component - Core Library
symfony/security-csrf                v5.2.1    Symfony Security Component - CSRF Library
symfony/security-guard               v5.2.1    Symfony Security Component - Guard
symfony/security-http                v5.2.1    Symfony Security Component - HTTP Integration
symfony/serializer                   v5.2.1    Symfony Serializer Component
symfony/service-contracts            v2.2.0    Generic abstractions related to writing services
symfony/stopwatch                    v5.2.1    Symfony Stopwatch Component
symfony/string                       v5.2.1    Symfony String component
symfony/translation                  v5.2.1    Symfony Translation Component
symfony/translation-contracts        v2.3.0    Generic abstractions related to translation
symfony/twig-bridge                  v5.2.1    Symfony Twig Bridge
symfony/twig-bundle                  v5.2.1    Symfony TwigBundle
symfony/validator                    v5.2.1    Symfony Validator Component
symfony/var-dumper                   v5.2.1    Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter                 v5.2.1    A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link                     v5.2.1    Symfony WebLink Component
symfony/web-profiler-bundle          v5.2.1    Symfony WebProfilerBundle
symfony/yaml                         v5.2.1    Symfony Yaml Component
...
theseer/tokenizer                    1.2.0     A small library for converting tokenized PHP source code into XML and potentially other formats
twig/extra-bundle                    v3.2.1    A Symfony bundle for extra Twig extensions
twig/twig                            v3.2.1    Twig, the flexible, fast, and secure template language for PHP
webmozart/assert                     1.9.1     Assertions to validate method input/output with nice error messages.

Description
I have a new project and required symfony/doctrine-messenger package. Afterwards I want to setup the migration via make:migration. The result is an error:
CleanShot 2021-01-21 at 21 55 25

The reason is, that I don't have any entites yet, so no mapping info available.

I created a new Test entity for testing purpose and run the command again... it works 🎉
CleanShot 2021-01-21 at 21 56 33

The result:

<?php

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20210121205631 extends AbstractMigration
{
    public function up(Schema $schema) : void
    {
        $this->addSql('CREATE SEQUENCE test_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
        $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
        $this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
        $this->addSql('BEGIN;');
        $this->addSql('LOCK TABLE messenger_messages;');
        $this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$
            BEGIN
                PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text);
                RETURN NEW;
            END;
        $$ LANGUAGE plpgsql;');
        $this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
        $this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();');
        $this->addSql('COMMIT;');
    }

    public function down(Schema $schema) : void
    {
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('DROP SEQUENCE test_id_seq CASCADE');
        $this->addSql('DROP TABLE test');
        $this->addSql('DROP TABLE messenger_messages');
    }
}

How to reproduce
I created a reproducer: https://github.com/OskarStark/reproducer-doctrine-messenger

Check the README 👀

Possible Solution

Additional context
It works as long you have any mapping info available .... 🤔

EDIT
I also tried to add auto_setup=false to the DSN, same result...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy