Hello all. Doctrine is a great ORM, but I have some doubts if I can say the same about it's migrations...
First of all I would like to say that current migrations generator for Doctrine is completely unusable, or I'm getting things wrong... Whatever I generate them I always get a migrations that contains only create tables statements. Why do I need it if I have more handy (in this case) symfony build-db and symfony insert-sql ? Also there are few flaws in the `symfony doctrine-generate-migrations- db`: for example it tries to include migration_version table into my model and doesn't recognize it as it's own meta table :) Another issue is that there's a hardcoded path ($directory = '/tmp/ tmp_doctrine_models') which doesn't work on neither windows machine nor hosting server :) One more is the whole method Doctrine_Migration_Builder::dataToPhpCode() which can be completely replaced by var_export($..., true), and performance will be even better (All of these are still correct for the trunk version http://doctrine.pengus.net/trac/browser/trunk/lib/Doctrine/Migration/Builder.php at the moment) So... returning to the topic... I'm looking for a way how to generate migrations sketches automatically. For example, when I change my model (schema.yml or model classes) I already express what changes I do to the model. Why not just use this knowledge and generate migrations by comparing my model with prev. version? For my personal case using of pristine svn copy for comparing is going to be ok. Let me describe the process as I see it. For example I have the following schema (that stays in the pristine svn copy after I alter the model): Card: columns: from_id: type: integer(4) Consider I change this file to the following by renaming `from_id` to `to_id` Card: columns: to_id: type: integer(4) What I've changed can be described in diff terms as: 1) drop column from_id 2) add column to_id integer(4) (instead of drop table, create table...) So... as I said before, I would like to automatically get a migration that would contain such statements: class Migration_{$from_revision_id} extends Doctrine_Migration { public function up() { $this->dropColumn('card', ''from_id') $this->addColumn('card', "to_id", "integer", array("length" => 4)); } public function down() { $this->dropColumn('card', ''to_id') $this->addColumn('card', "from_id", "integer", array("length" => 4)); } } This migration would be stored in "{$migration_increment}_{$from_revision_id}_{$smth}.class.php". $from_revision_id is needed to identify the migration to replace if the generator is executed once again (for example if someone wants to rebuild migration after he changed the model/schema once again). It will give me an idea of what have been changed in model since last commit (and probably a ready migration in simple cases) and I won't have to check `svn diff`, and build a migration from scratch. I prefer to read the code instead of writing it :) Of course in this example I would then fix the generated migration to use renameColumn(), but it would be much easier, as far as I see the complete scope of work, and as far as I have very similar statements, so I can copy-paste... A bit more about advantages... As I imagine, my whole development cycle would look this way: 1) change model; 2) generate migration; 3) check and alter migration (alter isn't required for simple model changes like adding/dropping column, adding/dropping table, etc...); 4) if need to change model again before commit goto 1; 5) commit; 6) go to 1; Not hard, eh? :) Any comments, suggestions, workarounds are highly appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---
