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

Add attributes metadata support #113

Closed
jurgenbosch opened this issue Aug 30, 2021 · 7 comments
Closed

Add attributes metadata support #113

jurgenbosch opened this issue Aug 30, 2021 · 7 comments

Comments

@jurgenbosch
Copy link

jurgenbosch commented Aug 30, 2021

Doctrine ORM 2.9 now supports Attributes mapping. According to this ticket the support for such attributes was added in some of the latest versions of the ORM package.

Unfortunately this appears not to work for the migrations.

Is there any plan to support this? It currently stops us from adapting this new annotation style (that I really like ;))

Thanks in advance.

@eigan
Copy link
Member

eigan commented Aug 30, 2021

Copy-paste reply from me in a different thread:

As of now laravel-doctrine do not have any maintainer that moves the project forward. Almost all contributions are provided from non team members. We are just making sure that pull requests are merged and released. It might appear that we do not even use laravel-doctrine, but the reason (for me at least) is that we do not keep up with the laravel/doctrine packages and features

So, no there is no plans, however I am active and will answer questions. Sadly I have no time to implement or look for solutions.

Our setup as of now: laravel 8, doctrine 2.9 and PHP 7.4. Plan is to upgrade to PHP 8 by this year which means that these issues will be sorted out by me, unless someone else provide PR :)

@jurgenbosch
Copy link
Author

Thanks for the quick reply.
I did a really quick scan of the procedure to detect the differences to see if there is a way I can help.
Are you doing some kind of regex to detect the annotations? If so maybe I can put some time in to make it work for the new PHP8 annotations.

PS. I'm currently using Laravel 8, Doctrine 2.9 and PHP 8.0.9 and the package works just fine with that setup.

@eigan
Copy link
Member

eigan commented Aug 30, 2021

I have not tested PHP 8 annotations with doctrine at all actually. Just assumed that doctrine would handle it when using the correct config (as the PR in this repo introduced).

@jurgenbosch
Copy link
Author

@eigan Is there any progress on the upgrade to PHP8? Maybe a better question; Is this package still considered to be alive as the last change is close to a year old.

@eigan
Copy link
Member

eigan commented Jan 7, 2022

Hello, I am here and project is still alive even no activity. I am just thinking it's a sign that it works for everyone perhaps :)

Our codebase has been ready for PHP 8 for a while, just waiting for the "Operation Team" to upgrade.. so I have not yet tested annotation, have you?

@dpslwk
Copy link
Member

dpslwk commented Jan 21, 2022

My testing show that doctrine:migrations:diff works just fine with DOCTRINE_METADATA=attributes

<?php

namespace App\Entities;

use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Table;

#[Entity]
#[Table(name: "user")]
class User
{
    #[Id, Column(type: "integer"), GeneratedValue()]
    protected $id = null;

    #[Column(type: "string", length: 32, unique: true, nullable: false)]
    protected $username;

    #[Column(type: "string", length: 32, unique: true, nullable: false)]
    protected $email;
}
<?php

namespace Database\Migrations;

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

class Version20220121162247 extends AbstractMigration
{
    /**
     * @param Schema $schema
     */
    public function up(Schema $schema): void
    {
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(32) NOT NULL, email VARCHAR(32) NOT NULL, UNIQUE INDEX UNIQ_8D93D649F85E0677 (username), UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
    }

    /**
     * @param Schema $schema
     */
    public function down(Schema $schema): void
    {
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('DROP TABLE user');
    }
}

@dpslwk
Copy link
Member

dpslwk commented Mar 24, 2022

closing until there is a supplied bug/issue/example of what down not work

@dpslwk dpslwk closed this as completed Mar 24, 2022
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