Doctrine 1
  1. Doctrine 1
  2. DC-750

migration error when deleting 2 or more related classes

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Migrations
    • Labels:
      None

      Description

      That's my relevant schema.yml before changes:

      Customer:
      columns:
      [..]

      CustomerPlace:
      columns:
      [..]
      relations:
      Customer:
      local: customer_id
      foreignAlias: Addresses
      onDelete: CASCADE

      CustomerPerson:
      columns:
      [..]
      relations:
      CustomerPlace:
      local: place_id
      foreignAlias: Contacts
      onDelete: CASCADE

      I deleted all of the 3 entities, I executed symfony doctrine:generate-migrations-diff, which created the migration file containing:

          
              $this->dropTable('customer');
              $this->dropTable('customer_person');
              $this->dropTable('customer_place');
      

      Executing the migration, gave me error for constrain violation. To fix the error, I added:

              $this->dropForeignKey('customer_person', 'customer_person_place_id_customer_place_id');
              $this->dropForeignKey('customer_place', 'customer_place_customer_id_customer_id');
      

      Thanks.

        Activity

        Hide
        Giovanni Toraldo added a comment - - edited

        Another way for fixing this issue, could be to generate a migration class for each of the related tables, so they are executed in different transaction, so integrity constrains aren't violated.

        Show
        Giovanni Toraldo added a comment - - edited Another way for fixing this issue, could be to generate a migration class for each of the related tables, so they are executed in different transaction, so integrity constrains aren't violated.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Giovanni Toraldo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: