Uploaded image for project: 'Doctrine DBAL'
  1. Doctrine DBAL
  2. DBAL-54

Incorrect sequence dropping in PostgreSQL


    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: 2.0.0-RC1-RC3
    • Component/s: Platforms
    • Labels:
    • Environment:
      postgresql 8.4.3, Arch Linux 64-bit


      Currently, DBAL drops the PostgreSQL sequences using the query:

      DROP SEQUENCE sequencename

      While it is quite correct at the first look, it fails, if the sequence is actually used by a table. Because Doctrine 2 ORM tries to drop the sequences before the tables, it makes impossible to drop a database schema in PostgreSQL due to the following exception:

      $ php53 doctrine.php orm:schema-tool:drop
      Dropping database schema...
      SQLSTATE[2BP01]: Dependent objects still exist: 7 ERROR: cannot drop sequence admins_id_seq because other objects depend on it
      DETAIL: default for table admins column id depends on sequence admins_id_seq
      HINT: Use DROP ... CASCADE to drop the dependent objects too.
      Line 570
      0. PDO::query on line 570
      1. Doctrine\DBAL\Connection::executeQuery on line 484
      2. Doctrine\ORM\Tools\SchemaTool::dropSchema on line 78
      3. Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand::executeSchemaCommand on line 59
      4. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand::execute on line 159
      5. Symfony\Component\Console\Command\Command::run on line 205
      6. Symfony\Component\Console\Application::doRun on line 117
      7. Symfony\Component\Console\Application::run on line 7

      A solution is simply to add the "CASCADE" keyword at the end of the query.

      Although I encountered this problem on DBAL 2.0-beta4, I checked the most up-to-date code on Git, and the problem is still present there.



          • Assignee:
            beberlei Benjamin Eberlei
            zyxist Tomasz Jędrzejewski
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: