laravel-doctrine/migrations

Add support for Laravel 9

yurybohush opened this issue ยท 30 comments

Hello! Please support for Laravel ver. 9.x ๐Ÿ‘๐Ÿ‘๐Ÿ‘

It will happen but in order to support laravel 9 we first need to move up todoctrine/migrations 3.x (due to the under lying need to be symfony 6).
This is not a small change and is going to need a lot more work (and hence time) than updating that was needed for the other packages in laravel-doctrine project

How long to wait? A few days or weeks?

eigan commented

@yurybohush Expect weeks

Hi, everyone.
doctrine/migrations already had version 3.x
and symfony version 6.x
what's next?

how much longer to wait?

longer every time you ask

there is a PR in the works #118 (have at trying it yourself)
but its waiting for me to find some time to review it

any news about this ?

eigan commented

Our client want to upgrade to L9 before support ends in jan 23. So I will start spending some time fixing the remaining issues and merging the pull request before that.

Just letting you know that I'm testing the 3.x branch and it generates the mysql dump file for every executed migration.
Is this intended behevariour?

eigan commented

Thanks @rkazaniszyn! We try to be 1-1 with the argument and options from doctrine/migrations. I guess we send the wrong default value in this case.

Thanks @rkazaniszyn! We try to be 1-1 with the argument and options from doctrine/migrations. I guess we send the wrong default value in this case.

@eigan I believe this was due to default value mismatch of write-sql (whereis it's null here and false in upstream) I have a fix for it here #122

Do we have any ETA for the v3 release? Very soon will be released Laravel 10 and we are still on 8 because of this package :(

eigan commented

@akalongman Use "laravel-doctrine/migrations": "3.x-dev" in composer.json. We will be using it in production from thursday. Will probably release next week if we get thumbs up from staging env (released to staging this week).

@eigan after upgrading, I have an error: Doctrine\Common\Annotations\AnnotationException : [Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class App\Entities\User was never imported. Did you maybe forget to add a "use" statement for this annotation?
Can it be related to this package?

eigan commented

@akalongman I did not see that particular error when upgrading. Is that User entity a laravel-doctrine entity?

Take a look at other packages upgraded and see if there is any breaking changes related for your codebase. I know we now allow doctrine/dbal 3.0 (via doctrine/migrations), which might cause other packages to be bumped to a new major.

https://github.com/doctrine/migrations/blob/3.5.x/UPGRADE.md#upgrade-to-31
https://github.com/doctrine/dbal/blob/3.5.x/UPGRADE.md#upgrade-to-30

Please let me know if you find out that the issue is, in case other people stumble upon it too ๐Ÿ™‚

@eigan my versions (doctrine packages):

beberlei/doctrineextensions                    v1.3.0
doctrine/annotations                           1.14.2
doctrine/cache                                 1.13.0
doctrine/collections                           1.8.0
doctrine/common                                3.4.3
doctrine/data-fixtures                         1.6.3
doctrine/dbal                                  2.13.9
doctrine/deprecations                          v0.5.3
doctrine/event-manager                         1.2.0
doctrine/inflector                             2.0.6
doctrine/instantiator                          1.5.0
doctrine/lexer                                 1.2.3
doctrine/migrations                            3.4.2
doctrine/orm                                   2.14.0
doctrine/persistence                           2.5.6
gedmo/doctrine-extensions                      v3.10.0
laravel-doctrine/extensions                    1.5.1
laravel-doctrine/migrations                    3.x-dev b096637
laravel-doctrine/orm                           1.8.1
ramsey/uuid-doctrine                           1.8.2

And my entity (shortened version):

<?php

declare(strict_types=1);

namespace App\Domain\Models\Identity;

use App;
use App\Domain\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Ramsey\Uuid\UuidInterface;

/**
 * @ORM\Entity
 * @ORM\Table(
 *     name="users",
 *     indexes={
 *         @ORM\Index(name="idx_email", columns={"email"}),
 *         @ORM\Index(name="idx_type", columns={"type"}),
 *     },
 * )
 * @Gedmo\Loggable
 */
class User extends Entity implements AuthenticatableContract
{
    use Authenticatable;

    /**
     * @ORM\Id
     * @ORM\Column(type="uuid_binary")
     */
    protected UuidInterface $id;
    /**
     * @Gedmo\Versioned
     * @ORM\Column(type="string")
     */
    protected string $email;
    /**
     * @Gedmo\Versioned
     * @ORM\Column(type="string")
     */
    protected string $type;

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

And I am getting this error: Doctrine\Common\Annotations\AnnotationException : [Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class App\Domain\Models\Identity\User was never imported. Did you maybe forget to add a "use" statement for this annotation?

This error definitely related to package version upgrades, on Laravel 8 (and old doctrine packages) this is working.

I have the same error(

laravel-doctrine/migrations should not cause this since "@doctrine\ORM\Mapping\Entity" is part of the orm not migrations
so its something from laravel-doctrine/orm and more the underlying doctrine/annotations package version

eigan commented

Please use xdebug and try to figure out why the exception is thrown, iam sorry but it's really hard to help without a reproduceable scenario.

Tips for breakpoints:

  • Doctrine\ORM\Mapping\Driver::loadMetadataForClass()
    • From here will it try to read your entities and the imports with aliases. It is not able to, figure out by stepping through the code-paths. The call this->reader->getClassAnnotations() is important, it will call setImports on DocParser.
  • Doctrine\Common\Annotations\DocParser::setImports
    • This should be called with all your imports above the entity, so orm should be a key pointing to Doctrine\ORM\Mapping.
    • Apparently this is not called I guess.

Note: I would expect you have cleared all your cache, as this information might be stored there.

@eigan I'll open this issue under laravel-doctrine/orm repo and will try to debug it somehow.

This error is not caused by the laravel-doctrine/migrations package.
In my other application, she appeared after

` composer update doctrine/orm ๎‚ฒ โœ” ๎‚ฒ 24s ๏‰’ ๎‚ฒ 14:41:05 ๏€— ๎‚ฒ 300 Mbps ๏‡ซ
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals

  • Upgrading doctrine/orm (2.13.4 => 2.14.1)
    `
    Updating doctrine/annotations to 1.14.2 didn't break my project
eigan commented

@yurybohush We found the issue related to how we use annotations in the extensions and acl libs laravel-doctrine/orm#537 ๐Ÿ™‚

@eigan now I suppose you can release the stable version for Laravel 9?

I've taken 3.x-dev for a thorough spin on a sizeable project that I look after, and everything works a treat. Thank you very much for the continued effort involved with this.

eigan commented

@ldebrouwer Thanks for letting us now, great to hear! :)

I found some more things I wanted to change before releasing. But will be released soon. Recent changes include: support new configuration structure, added more commands, fix issues with execute command, organize_migrations key was ignored.

According to the doctrine/migrations changelog the version column is now the FQCN and existing entries should be automatically updated (https://github.com/doctrine/migrations/blob/3.5.x/UPGRADE.md#upgrade-to-31) but it doesn't happen to me.
I am pretty sure that when I tested this package last time (the 3.x branch) few weeks ago it worked fine and updated my entries to fully qualified class names once I run the doctrine:migrations:migrate command but now it doesn't work.
Could you please take a look at it?

^ It works just fine with this fork https://github.com/Wisepops/migrations

eigan commented

@radektidio I am not able to reproduce, could you open a new issue where you describe the issue and what you have tried?

To be clear, the wisepops repo is the primary commit for the 3.x branch. We have had some adjustments after this.

@eigan I just double-checked it and everything works fine. I just needed to revert the version column to varchar(14) to make it work properly.
Sorry for confusion :)

eigan commented

Released 3.0.0 now. Thank you to everyone using the 3.x branch and reporting issues! ๐Ÿค ๐Ÿ‘๐Ÿป