dbal icon indicating copy to clipboard operation
dbal copied to clipboard

Diffing Sqlite Schema can in certain conditions lead to illegal alter table generation due to missing platform feature check

Open beberlei opened this issue 4 years ago • 10 comments

BC Break Report

Q A
BC Break yes
Version 2.10.3

Summary

Following https://github.com/symfony/symfony/issues/38067 the schema diff functionality in combination with Sqlite can lead to an illegal alter table statement generation that Sqlite des not support, causing an exception. This is due to a missing guard statement for a platform feature flag check.

Previous behaviour

Before 2.10.3, Sqlite did not generate foreign keys and as such this behavior was not present.

Current behavior

Leads to an exception:

$ php bin/console make:migration -v

In SqlitePlatform.php line 827:
                                                                                                                 
  [Doctrine\DBAL\DBALException]                                                                                  
  Sqlite platform does not support alter foreign key, the table must be fully recreated using getAlterTableSQL.  
                                                                                                                 

Exception trace:
  at /home/marcel/Projekte/02_WEB/scheduly/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php:827
 Doctrine\DBAL\Platforms\SqlitePlatform->getDropForeignKeySQL() at /home/marcel/Projekte/02_WEB/scheduly/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php:121
 Doctrine\DBAL\Schema\SchemaDiff->_toSql() at /home/marcel/Projekte/02_WEB/scheduly/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php:101
 Doctrine\DBAL\Schema\SchemaDiff->toSql() at /home/marcel/Projekte/02_WEB/scheduly/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Schema.php:442
 Doctrine\DBAL\Schema\Schema->getMigrateFromSql() at /home/marcel/Projekte/02_WEB/scheduly/vendor/doctrine/migrations/lib/Doctrine/Migrations/Generator/DiffGenerator.php:94
 Doctrine\Migrations\Generator\DiffGenerator->generate() at /home/marcel/Projekte/02_WEB/scheduly/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/DiffCommand.php:145
 Doctrine\Migrations\Tools\Console\Command\DiffCommand->execute() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/console/Command/Command.php:258
 Symfony\Component\Console\Command\Command->run() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/maker-bundle/src/Maker/MakeMigration.php:93
 Symfony\Bundle\MakerBundle\Maker\MakeMigration->generate() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/maker-bundle/src/Command/MakerCommand.php:104
 Symfony\Bundle\MakerBundle\Command\MakerCommand->execute() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/console/Command/Command.php:258
 Symfony\Component\Console\Command\Command->run() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/console/Application.php:934
 Symfony\Component\Console\Application->doRunCommand() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/framework-bundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/console/Application.php:264
 Symfony\Component\Console\Application->doRun() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/framework-bundle/Console/Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/marcel/Projekte/02_WEB/scheduly/vendor/symfony/console/Application.php:140
 Symfony\Component\Console\Application->run() at /home/marcel/Projekte/02_WEB/scheduly/bin/console:43

make:migration [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

How to reproduce

See https://github.com/symfony/symfony/issues/38067#issuecomment-687745734

beberlei avatar Sep 06 '20 14:09 beberlei

@MarcelKr Can you explain if this is the first migration of the project, or a follow up migration? The stacktrace seems to suggest an entity or table gets removed, that is why I am asking.

beberlei avatar Sep 06 '20 14:09 beberlei

It was the first time I executed symfony's make:migration after creating some entitys via make:entity

After downgrading dbal to 2.10.2 and looking at the generated migration, there's only generate table and index commands. It looks correct.

MarcelKr avatar Sep 06 '20 14:09 MarcelKr

@MarcelKr could you go into Doctrine\DBAL\Schema\SchemaDiff->toSql() and var_dump($this); on 2.10.3? it would help me understand whats what.

beberlei avatar Sep 06 '20 14:09 beberlei

Sure, here you go:

Doctrine\DBAL\Schema\SchemaDiff {#408
  +fromSchema: Doctrine\DBAL\Schema\Schema {#499
    -namespaces: []
    #_tables: []
    #_sequences: []
    #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#234
      #hasExplicitForeignKeyIndexes: false
      #maxIdentifierLength: 63
      #name: "/home/marcel/Projekte/02_WEB/scheduly/var/data.db"
      #defaultTableOptions: array:1 [
        "charset" => "utf8"
      ]
    }
    #_name: "db"
    #_namespace: "/home/marcel/Projekte/02_WEB/scheduly/var/data"
    #_quoted: false
  }
  +newNamespaces: []
  +removedNamespaces: []
  +newTables: array:4 [
    "attendee" => Doctrine\DBAL\Schema\Table {#391
      #_columns: array:4 [
        "id" => Doctrine\DBAL\Schema\Column {#437
          #_type: Doctrine\DBAL\Types\IntegerType {#255}
          #_length: null
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: true
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "id"
          #_namespace: null
          #_quoted: false
        }
        "first_name" => Doctrine\DBAL\Schema\Column {#383
          #_type: Doctrine\DBAL\Types\StringType {#350}
          #_length: 50
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: false
          #_default: null
          #_autoincrement: false
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "first_name"
          #_namespace: null
          #_quoted: false
        }
        "last_name" => Doctrine\DBAL\Schema\Column {#380
          #_type: Doctrine\DBAL\Types\StringType {#350}
          #_length: 50
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: false
          #_default: null
          #_autoincrement: false
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "last_name"
          #_namespace: null
          #_quoted: false
        }
        "email" => Doctrine\DBAL\Schema\Column {#379
          #_type: Doctrine\DBAL\Types\StringType {#350}
          #_length: 255
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: false
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "email"
          #_namespace: null
          #_quoted: false
        }
      ]
      -implicitIndexes: []
      #_indexes: array:1 [
        "primary" => Doctrine\DBAL\Schema\Index {#378
          #_columns: array:1 [
            "id" => Doctrine\DBAL\Schema\Identifier {#424
              #_name: "id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_isUnique: true
          #_isPrimary: true
          #_flags: []
          -options: []
          #_name: "primary"
          #_namespace: null
          #_quoted: false
        }
      ]
      #_primaryKeyName: "primary"
      #_fkConstraints: []
      #_options: array:2 [
        "create_options" => []
        "charset" => "utf8"
      ]
      #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393
        #hasExplicitForeignKeyIndexes: false
        #maxIdentifierLength: 63
        #name: "/home/marcel/Projekte/02_WEB/scheduly/var/data.db"
        #defaultTableOptions: array:1 [
          "charset" => "utf8"
        ]
      }
      #_name: "attendee"
      #_namespace: null
      #_quoted: false
    }
    "course" => Doctrine\DBAL\Schema\Table {#410
      #_columns: array:6 [
        "id" => Doctrine\DBAL\Schema\Column {#411
          #_type: Doctrine\DBAL\Types\IntegerType {#255}
          #_length: null
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: true
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "id"
          #_namespace: null
          #_quoted: false
        }
        "title" => Doctrine\DBAL\Schema\Column {#412
          #_type: Doctrine\DBAL\Types\StringType {#350}
          #_length: 255
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: false
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "title"
          #_namespace: null
          #_quoted: false
        }
        "description" => Doctrine\DBAL\Schema\Column {#413
          #_type: Doctrine\DBAL\Types\TextType {#256}
          #_length: null
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: false
          #_default: null
          #_autoincrement: false
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "description"
          #_namespace: null
          #_quoted: false
        }
        "starts_at" => Doctrine\DBAL\Schema\Column {#414
          #_type: Doctrine\DBAL\Types\DateTimeType {#269}
          #_length: null
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: false
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "starts_at"
          #_namespace: null
          #_quoted: false
        }
        "ends_at" => Doctrine\DBAL\Schema\Column {#415
          #_type: Doctrine\DBAL\Types\DateTimeType {#269}
          #_length: null
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: false
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "ends_at"
          #_namespace: null
          #_quoted: false
        }
        "max_attendees" => Doctrine\DBAL\Schema\Column {#416
          #_type: Doctrine\DBAL\Types\IntegerType {#255}
          #_length: null
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: false
          #_default: null
          #_autoincrement: false
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "max_attendees"
          #_namespace: null
          #_quoted: false
        }
      ]
      -implicitIndexes: []
      #_indexes: array:1 [
        "primary" => Doctrine\DBAL\Schema\Index {#375
          #_columns: array:1 [
            "id" => Doctrine\DBAL\Schema\Identifier {#376
              #_name: "id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_isUnique: true
          #_isPrimary: true
          #_flags: []
          -options: []
          #_name: "primary"
          #_namespace: null
          #_quoted: false
        }
      ]
      #_primaryKeyName: "primary"
      #_fkConstraints: []
      #_options: array:2 [
        "create_options" => []
        "charset" => "utf8"
      ]
      #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393}
      #_name: "course"
      #_namespace: null
      #_quoted: false
    }
    "course_attendee" => Doctrine\DBAL\Schema\Table {#417
      #_columns: array:2 [
        "course_id" => Doctrine\DBAL\Schema\Column {#418
          #_type: Doctrine\DBAL\Types\IntegerType {#255}
          #_length: null
          #_precision: 10
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: false
          #_platformOptions: []
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "course_id"
          #_namespace: null
          #_quoted: false
        }
        "attendee_id" => Doctrine\DBAL\Schema\Column {#430
          #_type: Doctrine\DBAL\Types\IntegerType {#255}
          #_length: null
          #_precision: 10
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: false
          #_platformOptions: []
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "attendee_id"
          #_namespace: null
          #_quoted: false
        }
      ]
      -implicitIndexes: array:2 [
        "idx_b8e4b831591cc992" => Doctrine\DBAL\Schema\Index {#435
          #_columns: array:1 [
            "course_id" => Doctrine\DBAL\Schema\Identifier {#431
              #_name: "course_id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_isUnique: false
          #_isPrimary: false
          #_flags: []
          -options: []
          #_name: "IDX_B8E4B831591CC992"
          #_namespace: null
          #_quoted: false
        }
        "idx_b8e4b831bcfd782a" => Doctrine\DBAL\Schema\Index {#425
          #_columns: array:1 [
            "attendee_id" => Doctrine\DBAL\Schema\Identifier {#422
              #_name: "attendee_id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_isUnique: false
          #_isPrimary: false
          #_flags: []
          -options: []
          #_name: "IDX_B8E4B831BCFD782A"
          #_namespace: null
          #_quoted: false
        }
      ]
      #_indexes: array:3 [
        "idx_b8e4b831591cc992" => Doctrine\DBAL\Schema\Index {#435}
        "idx_b8e4b831bcfd782a" => Doctrine\DBAL\Schema\Index {#425}
        "primary" => Doctrine\DBAL\Schema\Index {#423
          #_columns: array:2 [
            "course_id" => Doctrine\DBAL\Schema\Identifier {#394
              #_name: "course_id"
              #_namespace: null
              #_quoted: false
            }
            "attendee_id" => Doctrine\DBAL\Schema\Identifier {#374
              #_name: "attendee_id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_isUnique: true
          #_isPrimary: true
          #_flags: []
          -options: []
          #_name: "primary"
          #_namespace: null
          #_quoted: false
        }
      ]
      #_primaryKeyName: "primary"
      #_fkConstraints: array:2 [
        "fk_b8e4b831591cc992" => Doctrine\DBAL\Schema\ForeignKeyConstraint {#419
          #_localTable: Doctrine\DBAL\Schema\Table {#417}
          #_localColumnNames: array:1 [
            "course_id" => Doctrine\DBAL\Schema\Identifier {#385
              #_name: "course_id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_foreignTableName: Doctrine\DBAL\Schema\Identifier {#382
            #_name: "course"
            #_namespace: null
            #_quoted: false
          }
          #_foreignColumnNames: array:1 [
            "id" => Doctrine\DBAL\Schema\Identifier {#381
              #_name: "id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_options: array:1 [
            "onDelete" => "CASCADE"
          ]
          #_name: "FK_B8E4B831591CC992"
          #_namespace: null
          #_quoted: false
        }
        "fk_b8e4b831bcfd782a" => Doctrine\DBAL\Schema\ForeignKeyConstraint {#429
          #_localTable: Doctrine\DBAL\Schema\Table {#417}
          #_localColumnNames: array:1 [
            "attendee_id" => Doctrine\DBAL\Schema\Identifier {#428
              #_name: "attendee_id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_foreignTableName: Doctrine\DBAL\Schema\Identifier {#427
            #_name: "attendee"
            #_namespace: null
            #_quoted: false
          }
          #_foreignColumnNames: array:1 [
            "id" => Doctrine\DBAL\Schema\Identifier {#426
              #_name: "id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_options: array:1 [
            "onDelete" => "CASCADE"
          ]
          #_name: "FK_B8E4B831BCFD782A"
          #_namespace: null
          #_quoted: false
        }
      ]
      #_options: array:2 [
        "create_options" => []
        "charset" => "utf8"
      ]
      #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393}
      #_name: "course_attendee"
      #_namespace: null
      #_quoted: false
    }
    "pending_confirmation" => Doctrine\DBAL\Schema\Table {#377
      #_columns: array:1 [
        "id" => Doctrine\DBAL\Schema\Column {#395
          #_type: Doctrine\DBAL\Types\IntegerType {#255}
          #_length: null
          #_precision: 0
          #_scale: 0
          #_unsigned: false
          #_fixed: false
          #_notnull: true
          #_default: null
          #_autoincrement: true
          #_platformOptions: array:1 [
            "version" => false
          ]
          #_columnDefinition: null
          #_comment: null
          #_customSchemaOptions: []
          #_name: "id"
          #_namespace: null
          #_quoted: false
        }
      ]
      -implicitIndexes: []
      #_indexes: array:1 [
        "primary" => Doctrine\DBAL\Schema\Index {#396
          #_columns: array:1 [
            "id" => Doctrine\DBAL\Schema\Identifier {#397
              #_name: "id"
              #_namespace: null
              #_quoted: false
            }
          ]
          #_isUnique: true
          #_isPrimary: true
          #_flags: []
          -options: []
          #_name: "primary"
          #_namespace: null
          #_quoted: false
        }
      ]
      #_primaryKeyName: "primary"
      #_fkConstraints: []
      #_options: array:2 [
        "create_options" => []
        "charset" => "utf8"
      ]
      #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393}
      #_name: "pending_confirmation"
      #_namespace: null
      #_quoted: false
    }
  ]
  +changedTables: []
  +removedTables: []
  +newSequences: []
  +changedSequences: []
  +removedSequences: []
  +orphanedForeignKeys: []
}
Doctrine\DBAL\Schema\SchemaDiff {#373
  +fromSchema: Doctrine\DBAL\Schema\Schema {#392
    -namespaces: []
    #_tables: array:4 [
      "/home/marcel/projekte/02_web/scheduly/var/data.db.attendee" => Doctrine\DBAL\Schema\Table {#391
        #_columns: array:4 [
          "id" => Doctrine\DBAL\Schema\Column {#437
            #_type: Doctrine\DBAL\Types\IntegerType {#255}
            #_length: null
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: true
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "id"
            #_namespace: null
            #_quoted: false
          }
          "first_name" => Doctrine\DBAL\Schema\Column {#383
            #_type: Doctrine\DBAL\Types\StringType {#350}
            #_length: 50
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: false
            #_default: null
            #_autoincrement: false
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "first_name"
            #_namespace: null
            #_quoted: false
          }
          "last_name" => Doctrine\DBAL\Schema\Column {#380
            #_type: Doctrine\DBAL\Types\StringType {#350}
            #_length: 50
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: false
            #_default: null
            #_autoincrement: false
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "last_name"
            #_namespace: null
            #_quoted: false
          }
          "email" => Doctrine\DBAL\Schema\Column {#379
            #_type: Doctrine\DBAL\Types\StringType {#350}
            #_length: 255
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: false
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "email"
            #_namespace: null
            #_quoted: false
          }
        ]
        -implicitIndexes: []
        #_indexes: array:1 [
          "primary" => Doctrine\DBAL\Schema\Index {#378
            #_columns: array:1 [
              "id" => Doctrine\DBAL\Schema\Identifier {#424
                #_name: "id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_isUnique: true
            #_isPrimary: true
            #_flags: []
            -options: []
            #_name: "primary"
            #_namespace: null
            #_quoted: false
          }
        ]
        #_primaryKeyName: "primary"
        #_fkConstraints: []
        #_options: array:2 [
          "create_options" => []
          "charset" => "utf8"
        ]
        #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393
          #hasExplicitForeignKeyIndexes: false
          #maxIdentifierLength: 63
          #name: "/home/marcel/Projekte/02_WEB/scheduly/var/data.db"
          #defaultTableOptions: array:1 [
            "charset" => "utf8"
          ]
        }
        #_name: "attendee"
        #_namespace: null
        #_quoted: false
      }
      "/home/marcel/projekte/02_web/scheduly/var/data.db.course" => Doctrine\DBAL\Schema\Table {#410
        #_columns: array:6 [
          "id" => Doctrine\DBAL\Schema\Column {#411
            #_type: Doctrine\DBAL\Types\IntegerType {#255}
            #_length: null
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: true
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "id"
            #_namespace: null
            #_quoted: false
          }
          "title" => Doctrine\DBAL\Schema\Column {#412
            #_type: Doctrine\DBAL\Types\StringType {#350}
            #_length: 255
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: false
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "title"
            #_namespace: null
            #_quoted: false
          }
          "description" => Doctrine\DBAL\Schema\Column {#413
            #_type: Doctrine\DBAL\Types\TextType {#256}
            #_length: null
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: false
            #_default: null
            #_autoincrement: false
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "description"
            #_namespace: null
            #_quoted: false
          }
          "starts_at" => Doctrine\DBAL\Schema\Column {#414
            #_type: Doctrine\DBAL\Types\DateTimeType {#269}
            #_length: null
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: false
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "starts_at"
            #_namespace: null
            #_quoted: false
          }
          "ends_at" => Doctrine\DBAL\Schema\Column {#415
            #_type: Doctrine\DBAL\Types\DateTimeType {#269}
            #_length: null
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: false
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "ends_at"
            #_namespace: null
            #_quoted: false
          }
          "max_attendees" => Doctrine\DBAL\Schema\Column {#416
            #_type: Doctrine\DBAL\Types\IntegerType {#255}
            #_length: null
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: false
            #_default: null
            #_autoincrement: false
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "max_attendees"
            #_namespace: null
            #_quoted: false
          }
        ]
        -implicitIndexes: []
        #_indexes: array:1 [
          "primary" => Doctrine\DBAL\Schema\Index {#375
            #_columns: array:1 [
              "id" => Doctrine\DBAL\Schema\Identifier {#376
                #_name: "id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_isUnique: true
            #_isPrimary: true
            #_flags: []
            -options: []
            #_name: "primary"
            #_namespace: null
            #_quoted: false
          }
        ]
        #_primaryKeyName: "primary"
        #_fkConstraints: []
        #_options: array:2 [
          "create_options" => []
          "charset" => "utf8"
        ]
        #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393}
        #_name: "course"
        #_namespace: null
        #_quoted: false
      }
      "/home/marcel/projekte/02_web/scheduly/var/data.db.course_attendee" => Doctrine\DBAL\Schema\Table {#417
        #_columns: array:2 [
          "course_id" => Doctrine\DBAL\Schema\Column {#418
            #_type: Doctrine\DBAL\Types\IntegerType {#255}
            #_length: null
            #_precision: 10
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: false
            #_platformOptions: []
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "course_id"
            #_namespace: null
            #_quoted: false
          }
          "attendee_id" => Doctrine\DBAL\Schema\Column {#430
            #_type: Doctrine\DBAL\Types\IntegerType {#255}
            #_length: null
            #_precision: 10
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: false
            #_platformOptions: []
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "attendee_id"
            #_namespace: null
            #_quoted: false
          }
        ]
        -implicitIndexes: array:2 [
          "idx_b8e4b831591cc992" => Doctrine\DBAL\Schema\Index {#435
            #_columns: array:1 [
              "course_id" => Doctrine\DBAL\Schema\Identifier {#431
                #_name: "course_id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_isUnique: false
            #_isPrimary: false
            #_flags: []
            -options: []
            #_name: "IDX_B8E4B831591CC992"
            #_namespace: null
            #_quoted: false
          }
          "idx_b8e4b831bcfd782a" => Doctrine\DBAL\Schema\Index {#425
            #_columns: array:1 [
              "attendee_id" => Doctrine\DBAL\Schema\Identifier {#422
                #_name: "attendee_id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_isUnique: false
            #_isPrimary: false
            #_flags: []
            -options: []
            #_name: "IDX_B8E4B831BCFD782A"
            #_namespace: null
            #_quoted: false
          }
        ]
        #_indexes: array:3 [
          "idx_b8e4b831591cc992" => Doctrine\DBAL\Schema\Index {#435}
          "idx_b8e4b831bcfd782a" => Doctrine\DBAL\Schema\Index {#425}
          "primary" => Doctrine\DBAL\Schema\Index {#423
            #_columns: array:2 [
              "course_id" => Doctrine\DBAL\Schema\Identifier {#394
                #_name: "course_id"
                #_namespace: null
                #_quoted: false
              }
              "attendee_id" => Doctrine\DBAL\Schema\Identifier {#374
                #_name: "attendee_id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_isUnique: true
            #_isPrimary: true
            #_flags: []
            -options: []
            #_name: "primary"
            #_namespace: null
            #_quoted: false
          }
        ]
        #_primaryKeyName: "primary"
        #_fkConstraints: array:2 [
          "fk_b8e4b831591cc992" => Doctrine\DBAL\Schema\ForeignKeyConstraint {#419
            #_localTable: Doctrine\DBAL\Schema\Table {#417}
            #_localColumnNames: array:1 [
              "course_id" => Doctrine\DBAL\Schema\Identifier {#385
                #_name: "course_id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_foreignTableName: Doctrine\DBAL\Schema\Identifier {#382
              #_name: "course"
              #_namespace: null
              #_quoted: false
            }
            #_foreignColumnNames: array:1 [
              "id" => Doctrine\DBAL\Schema\Identifier {#381
                #_name: "id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_options: array:1 [
              "onDelete" => "CASCADE"
            ]
            #_name: "FK_B8E4B831591CC992"
            #_namespace: null
            #_quoted: false
          }
          "fk_b8e4b831bcfd782a" => Doctrine\DBAL\Schema\ForeignKeyConstraint {#429
            #_localTable: Doctrine\DBAL\Schema\Table {#417}
            #_localColumnNames: array:1 [
              "attendee_id" => Doctrine\DBAL\Schema\Identifier {#428
                #_name: "attendee_id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_foreignTableName: Doctrine\DBAL\Schema\Identifier {#427
              #_name: "attendee"
              #_namespace: null
              #_quoted: false
            }
            #_foreignColumnNames: array:1 [
              "id" => Doctrine\DBAL\Schema\Identifier {#426
                #_name: "id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_options: array:1 [
              "onDelete" => "CASCADE"
            ]
            #_name: "FK_B8E4B831BCFD782A"
            #_namespace: null
            #_quoted: false
          }
        ]
        #_options: array:2 [
          "create_options" => []
          "charset" => "utf8"
        ]
        #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393}
        #_name: "course_attendee"
        #_namespace: null
        #_quoted: false
      }
      "/home/marcel/projekte/02_web/scheduly/var/data.db.pending_confirmation" => Doctrine\DBAL\Schema\Table {#377
        #_columns: array:1 [
          "id" => Doctrine\DBAL\Schema\Column {#395
            #_type: Doctrine\DBAL\Types\IntegerType {#255}
            #_length: null
            #_precision: 0
            #_scale: 0
            #_unsigned: false
            #_fixed: false
            #_notnull: true
            #_default: null
            #_autoincrement: true
            #_platformOptions: array:1 [
              "version" => false
            ]
            #_columnDefinition: null
            #_comment: null
            #_customSchemaOptions: []
            #_name: "id"
            #_namespace: null
            #_quoted: false
          }
        ]
        -implicitIndexes: []
        #_indexes: array:1 [
          "primary" => Doctrine\DBAL\Schema\Index {#396
            #_columns: array:1 [
              "id" => Doctrine\DBAL\Schema\Identifier {#397
                #_name: "id"
                #_namespace: null
                #_quoted: false
              }
            ]
            #_isUnique: true
            #_isPrimary: true
            #_flags: []
            -options: []
            #_name: "primary"
            #_namespace: null
            #_quoted: false
          }
        ]
        #_primaryKeyName: "primary"
        #_fkConstraints: []
        #_options: array:2 [
          "create_options" => []
          "charset" => "utf8"
        ]
        #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393}
        #_name: "pending_confirmation"
        #_namespace: null
        #_quoted: false
      }
    ]
    #_sequences: []
    #_schemaConfig: Doctrine\DBAL\Schema\SchemaConfig {#393}
    #_name: "db"
    #_namespace: "/home/marcel/Projekte/02_WEB/scheduly/var/data"
    #_quoted: false
  }
  +newNamespaces: []
  +removedNamespaces: []
  +newTables: []
  +changedTables: []
  +removedTables: array:4 [
    "attendee" => Doctrine\DBAL\Schema\Table {#391}
    "course" => Doctrine\DBAL\Schema\Table {#410}
    "course_attendee" => Doctrine\DBAL\Schema\Table {#417}
    "pending_confirmation" => Doctrine\DBAL\Schema\Table {#377}
  ]
  +newSequences: []
  +changedSequences: []
  +removedSequences: []
  +orphanedForeignKeys: array:2 [
    0 => Doctrine\DBAL\Schema\ForeignKeyConstraint {#429}
    1 => Doctrine\DBAL\Schema\ForeignKeyConstraint {#419}
  ]
}

MarcelKr avatar Sep 06 '20 14:09 MarcelKr

Ah the down sql generation is the problem, thank you. A fix should be straightforward

beberlei avatar Sep 06 '20 15:09 beberlei

@beberlei I have the same issue in version 3.4.5, is this still an issue? because I thought it got fixed

$ symfony console doctrine:migrations:diff
[critical] Error thrown while running command "doctrine:migrations:diff". Message: "Sqlite platform does not support alter foreign key."


In SqlitePlatform.php line 944:

  Sqlite platform does not support alter foreign key.  

renja-g avatar Oct 17 '22 09:10 renja-g

same issue with version 3.4.5. as well

alena424 avatar Nov 13 '22 17:11 alena424

Is there any hope to see this bug fixed one day or another ?

taophp avatar May 04 '23 09:05 taophp

@beberlei Now that NativePHP has been released, this bug becomes critical: indeed, NativePHP offers to work with SQLite, which is a relevant choice in this context. But this bug prohibits developing a Symfony application that can take advantage of NativePHP and closes to Symfony developers all the new ecosystem that has just opened.

taophp avatar Jul 23 '23 16:07 taophp

Just encountered this bug today, had to write a migration manually, afterwards it picked it up and generated a correct one.

RikudouSage avatar Jan 31 '24 09:01 RikudouSage