doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.65k stars 387 forks source link

Migration implicitly ALTERs unrelated tables #1430

Closed nicoSC closed 1 month ago

nicoSC commented 2 months ago

Bug Report

Q A
BC Break no
Version 3.7.4
MariaDB Version 10.5.21

Summary

A migration causes implicit changes to existing database tables that are not related to the migration

Current behavior

During the execution of a migration, SchemaDiffProvider is providing a diff of all tables in the database that results in my case in an ALTER TABLE statement to be executed, affecting a table that is not related to the migration that I am executing (neither to my application).

Background: I share a single database with different other teams. I have a set of tables I manage with doctrine, however, other teams might do the same with their tables. I have no control over which tables other teams have created or will create in the future.

How to reproduce

  1. Manually create table table1 in your database that has a column with type longtext and COMMENT '(DC2Type:json)'
  2. Create a migration that creates table table2.
  3. Run the migration (with --write-sql) 4.. Notice the ALTER TABLE statement for table1

Expected behavior

Running a migration only affects changes that the migration describes

greg0ire commented 1 month ago

I believe this should answer your question: https://www.doctrine-project.org/projects/doctrine-migrations/en/3.7/reference/generating-migrations.html#ignoring-custom-tables