Well, I think the title pretty much summarizes what occured to me today, you see… I’ve been using Yii for some months with some pretty cool results (I find it much more intuitive and simple than RoR, it’s also faster, more didactic and it’s on PHP, which is way more popular amongst hosting providers than Ruby is), the thing is I decided to try the migration tool today in order to keep a better control of the changes and versioning in the database (I usually write these things down in a text document with a nice but very long form, works pretty well but it’s a bit annoying) and it didn’t go as expected:
I created the migration with the
yiic migrate create migration_name
command (yes, I used the yiic in the app protected directory), at first it didn’t work at all, so I searched for a while until I stumbled upon someone saying that the migration tool needed SQLite to store the migration history, I usually work with Postgres or MySQL so I have both PDOs installed and apps running on both database managers, but I don’t like SQLite so I had to install the corresponding PDO and… It started the migration, cool! until… I got a nice error that looked something like this:
applying migration_name > add column column_name varchar(64) to table schema_name.table_name ...exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: 1 no such table: schema_name.table_name. The SQL statement executed was: ALTER TABLE 'schema_name'.'table_name' ADD "column_name" varchar(64)' in /var/www/yii/framework/db/CDbCommand.php:336
(I replaced some names in my database to avoid details). So I looked at it and noticed that it added single quotes to schema and table names, Postgres requires double quotes for this task, weird... A quick check on the corresponding classes revealed to me that it was using (as I thought) the PDO quote method, so that was not the problem, since I was a little bit confused because of this, I asked Yii to append the PDO driver name at the end of the error message, then the epiphany came to me: Yii was trying to use the SQLite driver to connect to a database that doesn't exist instead of my Postgres database, completely overriding what is set in my main.php config file... This isn't a critical error that will completely stop my developments, but confuses me a lot, has this happened to anyone else? Google says "no, dude, it's just you..." but, in any case, I would like some feedback on this issue from those who know more than I do before I wreck something trying to develop a (possibly) unnecessary workaround. Maybe it's something stupid but it doesn't hurt to ask (nor to answer). Some info about my environment:
-Running apache 2.2.17 with PHP 5.3.5 on Ubuntu 11.04.
-Yii version: 1.1.8 with MySQL, PostgreSQL and SQLite PDOs.
I'm eager to read your opinions on this topic.