Hello ORM/DBAL heroes,

I'm having two minor troubles with the ORM 2.4.* and DBAL 2.3.* functions.

I'm implementing a little database backup tool for our app 
(http://volkszaehler.org). Part of the functionality- which DBAL gracefully 
seems to offer- will be migrating from a MySQL DB to SQlite (or others).


1. Problem: Synching the schema from MySQL to SQLite, schema creation fails 
on SQlite side.

What happens is this that creating the schema on SQlite fails as a duplice 
ts_uniq constraint appears:

  [Doctrine\DBAL\DBALException]
  An exception occurred while executing 'CREATE UNIQUE INDEX ts_uniq ON 
data (channel_id, timestamp)':
  SQLSTATE[HY000]: General error: 1 index ts_uniq already exists


This is the SQL run:

CREATE TABLE aggregate (id INTEGER NOT NULL, channel_id INTEGER DEFAULT 
NULL, value DOUBLE PRECISION NOT NULL, count INTEGER NOT NULL, type INTEGER 
NOT NULL, timestamp INTEGER NOT NULL, PRIMARY KEY(id), CONSTRAINT 
FK_B77949FF72F5A1AA FOREIGN KEY (channel_id) REFERENCES entities (id) NOT 
DEFERRABLE INITIALLY IMMEDIATE)
CREATE UNIQUE INDEX ts_uniq ON aggregate (channel_id, type, timestamp)

CREATE TABLE data (id INTEGER NOT NULL, channel_id INTEGER DEFAULT NULL, 
value DOUBLE PRECISION NOT NULL, timestamp INTEGER NOT NULL, PRIMARY 
KEY(id), CONSTRAINT FK_ADF3F36372F5A1AA FOREIGN KEY (channel_id) REFERENCES 
entities (id) NOT DEFERRABLE INITIALLY IMMEDIATE)
CREATE UNIQUE INDEX ts_uniq ON data (channel_id, timestamp)

This is the code:

        $sc = .. // MySQL connection
        $tc = .. // SQlite connection

        $sm = $this->sc->getSchemaManager();

        $schema = $sm->createSchema();
        $synchronizer = new SingleDatabaseSynchronizer($this->tc);
        $synchronizer->createSchema($schema);


Question:

ts_uniq is apparently a name in table scope, while on SQlite it seems to be 
in global scope, thus generating a conflict. Is this the expected behaviour 
or is DBAL expected to resolve naming conflicts?


2. Problem: Solving the name conflict in the ORM model isn't synced

The ts_uniq names are coming from an ORM model, same constraint name used 
on `data` and `aggregate` table:

    @UniqueConstraint(name="ts_uniq", columns={...})

Trying to resolve the constraint name conflict in the ORM model, I've 
changed the @UniqueConstraint names to unique ones. However:

    doctrine.php orm:schema-tool:update
    Nothing to update - your database is already in sync with the current 
entity metadata.

Question:

Is it expected behaviour that the orm:schematool doesn't notice constraint 
name changes? orm:clear-cache:metadata wasn't helpful, either.

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to