I have a problem with creating gii generator.
The full story:
I’ve found Yii extension (now I can’t find that on the Yii site) - gii generator, that creates SQL migrations. I’ve improved the generator (at start It didn’t supported rollback of migrations, and I’ve added this support). The generator is working very fine, and helps me and my team to commit database changes into git, and have the same database structures at local machines, and on main server.
But, sooner I’ve understood that I need new generator, that creates migrations which would automatically fill some table with dumped data. For example, if someone works on a module, that require some DB tables filled with some initial data, he need to manually get dump from this tables, put it into migrate generator, and make a migration. Because of high frequency of this operations I’ve decided to write new generator - that would create migration cansists of sql, filling selected table with dump of local one.
And I’ve made it, Migrate Dump Generator. It’s generating what I want, except of the last stage - the file doesn’t write to the folder! This is a my problem…
As you know, gii generation consists of 3 or more steps:
-> enter data, needed to generate and press "Preview"
-> If there are no errors - you can click on the file in table “Code file” and view it’s content (this step is forks great for me), also you could uncheck files in this table, if you don’t want them to be generated.
-> press "Generate", to put generated file to the place where it have to be. At this step there are a grey frame appearing at the bottom of page, and showing the stages of progress. In my case, It shows something like this:
Generating code using template "./protected/gii/MigrateDump/templates/default"... skipped migrations/m130730_165814_user.php done!
I’ve digged into framework files, and found that “skipped” is written by operator on line 338 of file CCodeModel.php, and it used in case, when user unchecked checkbox near the file on “Preview” page of generator. But I didn’t unchecked this checkbox! I’ve tried to analyze this strange behavior with xdebug step-by-step execution, but no luck…
So, I need help from someone familiar with building generators… This bug is very strange, because of my generator is just a copy of first generator, mentioned here with little differencies…
I’ve put Migrate generator (the thing that work properly) to the github: github.com/MihanEntalpo/yii-sql-migration-generator
I’ve put Migrate Dump generator (the unworking one) to the github too: github.com/MihanEntalpo/yii-sql-migration-dump-generator