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 the abortIf check when generating a migration. #904

Closed
VincentLanglet opened this issue Jan 8, 2020 · 2 comments
Closed

Add the abortIf check when generating a migration. #904

VincentLanglet opened this issue Jan 8, 2020 · 2 comments
Milestone

Comments

@VincentLanglet
Copy link
Contributor

Feature Request

Q A
New Feature not really
BC Break don't know

Summary

When doing doctrine:migration:diff I get something like this:

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

        $this->addSql('ALTER TABLE asv_contract_operation CHANGE eligible_for_voucher eligible_for_bonus TINYINT(1) DEFAULT \'0\' NOT NULL');
    }

But when doing doctrine:migration:generate I get:

    /**
     * @param Schema $schema
     *
     * @throws MigrationException|DBALException
     */
    public function up(Schema $schema): void
    {
    }

I would expect to get:

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

    }
@goetas
Copy link
Member

goetas commented Jan 8, 2020

Duplicate of doctrine/DoctrineMigrationsBundle#270, will be solved with the v3.0

@goetas goetas closed this as completed Jan 8, 2020
@alcaeus
Copy link
Member

alcaeus commented Jan 8, 2020

In addition to the above, the reason the abortIf call is there because the auto-generated migration (which is done using diff) can only support the current platform. When calling the generate command, all you get is an empty migration with no database-specific code in it. If you add code that only works on a specific platform, it's your responsibility to do so.

This doesn't mean we won't add the call ever, I'm just explaining why it isn't added at the moment.

@goetas goetas added this to the 3.0.0 milestone Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants