doctrine:generate-migrations-diff && doctrine:migrate

556 views
Skip to first unread message

Stéphane Erard

unread,
May 27, 2010, 4:48:08 AM5/27/10
to apostrophenow
Hi list,

I'm having trouble when I need to recreate my db without data loss :
migrating.
Are you guys having trooble too when doing so ?
It's telling me there are errors with a_slot table.

Thank you

Abraham Block

unread,
May 27, 2010, 8:47:23 AM5/27/10
to apostr...@googlegroups.com
There is some information about this in the manual http://trac.apostrophenow.org/wiki/ManualInstallation pointing to a symfony bug report with some suggestions for how to deal this. I don't know if the new apostrophe:migrate task deals with this for you.

Stéphane

unread,
May 27, 2010, 8:52:39 AM5/27/10
to apostr...@googlegroups.com
Hi, thank you for the pointer.

I don't get this problem. The problem occurs when doctrine:migrate. Symfony throws me doctrine error that it cannot create table or alter table.

Cheers,

Before Printing, Think about Your Environmental Responsibility!
Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!

Abraham Block

unread,
May 27, 2010, 8:53:51 AM5/27/10
to apostr...@googlegroups.com
what is the error, and what is the generated sql?

Stéphane

unread,
May 27, 2010, 9:01:35 AM5/27/10
to apostr...@googlegroups.com
This is what I get when I do the symfony doctrine:migrate :

  - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'a_slot' already exists. Failing Query: "CREATE TABLE a_slot (id INT AUTO_INCREMENT, type VARCHAR(100), variant VARCHAR(100), value LONGTEXT, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE
utf8_general_ci ENGINE = INNODB"
   - SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'page_id'. Failing Query: "ALTER TABLE a_slot ADD page_id INT"

   - SQLSTATE[HY000]: General error: 1005 Can't create table 'asandbox.#sql-4e4_1' (errno: 121). Failing Query: "ALTER TABLE a_slot ADD CONSTRAINT a_slot_page_id_a_page_id FOREIGN KEY (page_id) REFERENCES a_page(id) ON DELETE CASCADE"

   - SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'a_slot_page_id_idx'. Failing Query: "CREATE INDEX
a_slot_page_id_idx ON a_slot (page_id)"

   - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'yd_text_content' already exists. Failing Query: "CREATE TABLE
yd_text_content (id BIGINT AUTO_INCREMENT, text LONGTEXT, title VARCHAR(255), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB"
   - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'yd_article' already exists. Failing Query: "CREATE TABLE yd_article (id BIGINT AUTO_INCREMENT, title VARCHAR(255) NOT NULL, text LONGTEXT, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB"


I don't know where the .sql file is generated.


Before Printing, Think about Your Environmental Responsibility!
Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!


Abraham Block

unread,
May 27, 2010, 9:23:56 AM5/27/10
to apostr...@googlegroups.com
First rule of migrations is always check two things before migrating:
1) The current migration version (in the migration table) and
2) The generated migration diff files (in lib/migrate/doctrine).

My guess here is that you are stuck on an early migration version that what you should be on. This usually happens, in my experience, after a failed migration.

For example:

1) Migration 2 created a table a_slot, but failed somewhere else.
2) The table a_slot will have been created, but the migration version is still set to 1
3) Try to as you may, you will always get an error when trying to migrate because the table exists. You will probably see something like "migrating from 1 to 3"

Also, the generated SQL is in the output you showed 

CREATE TABLE a_slot (id INT AUTO_INCREMENT, type VARCHAR(100), variant VARCHAR(100), value LONGTEXT, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE
utf8_general_ci ENGINE = INNODB

ALTER TABLE a_slot ADD page_id INT

etc.

Stéphane

unread,
May 27, 2010, 9:26:21 AM5/27/10
to apostr...@googlegroups.com
I know I have tried it with a fresh apostrophe installation.
I'll give it a new try to make a proper consideration about it. 

Thank you !

Before Printing, Think about Your Environmental Responsibility!
Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!


Reply all
Reply to author
Forward
0 new messages