Allow to ignore migration_versions in doctrine:schema:validate or provide a similar migraiton command #7451

Closed
opened 2026-01-22 15:51:50 +01:00 by admin · 2 comments
Owner

Originally created by @VincentLanglet on GitHub (Dec 5, 2024).

Feature Request

What

I'd like the ability to run doctrine:schema:validate when using migrations.
It requires

  • To be able to ignore the database diff which try to drop the table migration_version
  • Or to have another command to run for migrations.

Why

While it's not recommended to use both doctrine:migrations and doctrine:schema commands,
I find useful to have doctrine:schema:validate checking

  • That the mapping is correct (I didn't think any other command checking this)
  • That no migration need to be generated

In order to check the mapping, there is the option to run

bin/console do:schema:validate --skip-sync

But in order to check that no migration need to be generated (or runned) I didn't found the right command so far.

The command

doctrine:migrations:up-to-date

only check generated migrations, but does not report error on missing generated migrations

I basically would like a doctrine:migrations:diff but which success only if there is an empty diff.
Does an option to this command would be the right way to do it ?

Originally created by @VincentLanglet on GitHub (Dec 5, 2024). ### Feature Request #### What I'd like the ability to run `doctrine:schema:validate` when using migrations. It requires - To be able to ignore the database diff which try to drop the table `migration_version` - Or to have another command to run for migrations. #### Why While it's not recommended to use both `doctrine:migrations` and `doctrine:schema` commands, I find useful to have `doctrine:schema:validate` checking - That the mapping is correct (I didn't think any other command checking this) - That no migration need to be generated In order to check the mapping, there is the option to run ``` bin/console do:schema:validate --skip-sync ``` But in order to check that no migration need to be generated (or runned) I didn't found the right command so far. The command ``` doctrine:migrations:up-to-date ``` only check generated migrations, but does not report error on missing generated migrations I basically would like a `doctrine:migrations:diff` but which success only if there is an empty diff. Does an option to this command would be the right way to do it ?
admin closed this issue 2026-01-22 15:51:50 +01:00
Author
Owner

@greg0ire commented on GitHub (Dec 5, 2024):

Hi Vincent!

We discussed this during the Hackathon, here is what we wrote down:

Migrations instead of Schema?

why do we have SchemaTool? We could use migrations with a Metadata provider that is:
Case of create: Hardcoded list of empty migrations
Case of update: Hardcoded list of 1 migration that represents the current schema
This means that we need to introduce a new implementation of MetadataStorage.

So the plan would be to make doctrine/migrations mandatory, but the changelog table would be optional, and people would use doctrine:schema:validate only for mapping validation. There is a discussion about this here: https://github.com/doctrine/migrations/issues/1406#issuecomment-2402065262

I basically would like a doctrine:migrations:diff but which success only if there is an empty diff.

I think so too but, it would reside in the migrations package, which would become kind of mandatory

That's assuming the only reason doctrine:migrations:diff exits with a non zero status code is because there is no diff, and that's a big assumption, so the first thing to do would be to introduce a new command or a new flag just to check this.

If you want to work on this, I think this would be a good first step towards this new model.

@greg0ire commented on GitHub (Dec 5, 2024): Hi Vincent! We discussed this during the Hackathon, here is what we wrote down: ``` Migrations instead of Schema? why do we have SchemaTool? We could use migrations with a Metadata provider that is: Case of create: Hardcoded list of empty migrations Case of update: Hardcoded list of 1 migration that represents the current schema This means that we need to introduce a new implementation of MetadataStorage. ``` So the plan would be to make `doctrine/migrations` mandatory, but the changelog table would be optional, and people would use `doctrine:schema:validate` only for mapping validation. There is a discussion about this here: https://github.com/doctrine/migrations/issues/1406#issuecomment-2402065262 > I basically would like a doctrine:migrations:diff but which success only if there is an empty diff. I think so too but, it would reside in the migrations package, which would become kind of mandatory > That's assuming the only reason doctrine:migrations:diff exits with a non zero status code is because there is no diff, and that's a big assumption, so the first thing to do would be to introduce a new command or a new flag just to check this. If you want to work on this, I think this would be a good first step towards this new model.
Author
Owner

@VincentLanglet commented on GitHub (Dec 5, 2024):

Didn't know about this issue ; I'll close it to avoid the duplicate then

@VincentLanglet commented on GitHub (Dec 5, 2024): Didn't know about this issue ; I'll close it to avoid the duplicate then
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7451