Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-917

using generator strategy AUTO leads to duplicate squences drops (on PostgreSQL) when using inheritance

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Git Master
    • Fix Version/s: 2.0-RC2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      This is the base definition:
      https://github.com/knplabs/DoctrineUserBundle/blob/symfony2Security/Resources/config/doctrine/metadata/orm/Bundle.DoctrineUserBundle.Entity.User.dcm.xml

      It uses

             <id name="id" type="integer" column="id">
                 <generator strategy="AUTO" />
             </id>
      

      This class is inherited 2 times.
      When generating the drop sql it gives the following (note the user_user_like and user_user_interest entities use generator strategy IDENTITY):

      Soitgoes:foo lsmith$ app/main/console_dev doctrine:schema:drop --dump-sql
      DROP SEQUENCE doctrine_user_user_id_seq;
      DROP SEQUENCE doctrine_user_user_id_seq;
      DROP SEQUENCE doctrine_user_user_id_seq;
      DROP SEQUENCE doctrine_user_user_id_seq;
      ALTER TABLE user_user_like DROP CONSTRAINT user_user_like_user_id_fkey;
      ALTER TABLE user_user_like DROP CONSTRAINT user_user_like_user_like_id_fkey;
      ALTER TABLE user_user_interest DROP CONSTRAINT user_user_interest_user_id_fkey;
      ALTER TABLE user_user_interest DROP CONSTRAINT user_user_interest_user_interest_id_fkey;
      DROP TABLE user_user_like;
      DROP TABLE user_user_interest;
      DROP TABLE doctrine_user_user;
      DROP TABLE user_like;
      DROP TABLE user_interest
      

      Soitgoes:foo lsmith$ app/main/console_dev doctrine:schema:create --dump-sql
      ATTENTION: This operation should not be executed in an production enviroment.

      CREATE TABLE doctrine_user_user (id INT NOT NULL, username VARCHAR(255) NOT NULL, username_lower VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, is_active BOOLEAN NOT NULL, is_super_admin BOOLEAN NOT NULL, password VARCHAR(255) NOT NULL, algorithm VARCHAR(127) NOT NULL, salt VARCHAR(127) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, last_login TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, confirmation_token VARCHAR(127) DEFAULT NULL, remember_me_token VARCHAR(127) DEFAULT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, profile_token VARCHAR(10) NOT NULL, has_accepted_terms BOOLEAN NOT NULL, facebookID VARCHAR(50) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, gender VARCHAR(1) DEFAULT NULL, age INT DEFAULT NULL, phone_number VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id));
      CREATE UNIQUE INDEX doctrine_user_user_username_uniq ON doctrine_user_user (username);
      CREATE UNIQUE INDEX doctrine_user_user_username_lower_uniq ON doctrine_user_user (username_lower);
      CREATE UNIQUE INDEX doctrine_user_user_email_uniq ON doctrine_user_user (email);
      CREATE UNIQUE INDEX doctrine_user_user_facebookID_uniq ON doctrine_user_user (facebookID);
      CREATE TABLE user_user_like (user_id INT NOT NULL, user_like_id INT NULL, PRIMARY KEY(user_id, user_like_id));
      CREATE INDEX user_user_like_user_like_id_idx ON user_user_like (user_like_id);
      CREATE UNIQUE INDEX user_user_like_user_id_uniq ON user_user_like (user_id);
      CREATE TABLE user_user_interest (user_id INT NOT NULL, user_interest_id INT NULL, PRIMARY KEY(user_id, user_interest_id));
      CREATE INDEX user_user_interest_user_interest_id_idx ON user_user_interest (user_interest_id);
      CREATE UNIQUE INDEX user_user_interest_user_id_uniq ON user_user_interest (user_id);
      CREATE TABLE user_interest (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id));
      CREATE TABLE user_like (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id));
      CREATE SEQUENCE doctrine_user_user_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
      ALTER TABLE user_user_like ADD FOREIGN KEY (user_id) REFERENCES doctrine_user_user(id) NOT DEFERRABLE INITIALLY IMMEDIATE;
      ALTER TABLE user_user_like ADD FOREIGN KEY (user_like_id) REFERENCES user_like(id) NOT DEFERRABLE INITIALLY IMMEDIATE;
      ALTER TABLE user_user_interest ADD FOREIGN KEY (user_id) REFERENCES doctrine_user_user(id) NOT DEFERRABLE INITIALLY IMMEDIATE;
      ALTER TABLE user_user_interest ADD FOREIGN KEY (user_interest_id) REFERENCES user_interest(id) NOT DEFERRABLE INITIALLY IMMEDIATE
      

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Lukas Kahwe
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: