Codegen only new tables

thread: 5 messages  |  last: a year ago  |  started: saturday, march 20, 2010, 2:20 pm pdt


#1  |  kentpachi (France, EU) France
Saturday, March 20, 2010, 2:20 PM PDT

Hello people.

i'm working on a project where users can create their own modules with their own tables.

while installing a module i need to codegen again for new tables in the database.

i managed to do this (at least almost) by code without loading the codegen.php webpage

but , how do i codegen only new tables or changed tables ? this could save me a lot of time and CPU as the db may containes several tables. There's no need to codegen unmodified.

Is that possible, does it exists ?

thanks !

#2  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Saturday, March 20, 2010, 11:09 PM PDT

No... unfortunately, codegen really does need to look at all the tables, especially because there's no other way to tell whether or not certain relationships exist, etc.

In general, because of the way codegen architectures work, it may not necessarily be the best idea to architect a system where the business rules would automatically cause code to be rewritten / regenerated...

A better idea might be to architect the data model in more of a “meta data model” approach, where the fields of a given value can be dynamically created or generated by the business rules of the application as the user specifies those values...

Just a thought.

#3  |  kentpachi (France, EU) France
Sunday, March 21, 2010, 3:59 AM PDT

Hi

Well at this stage i cannot change the model, too bad.

however.

I see that in codegen there are many steps. one of them is generateaggregate().

It should be interesting to save the previous database schema in an xml file. TO anlayze the new one and compare whats changed .

So we could look for changes before doing this :

 DisplayMonospacedText($objCodeGen->GenerateAll()); 

and that

QCodeGen::GenerateAggregate() ;

it might be a way no ? what do you think ?

maybe this would be a killerfeature for 1.0

#4  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Sunday, March 21, 2010, 9:58 AM PDT

An interesting thought... but unfortunately the analysis is what I believe takes the longest part of the time when codegenning -- so even if something like what you suggest would be implemented, you wouldn't save a lot in terms of processing time.

#5  |  kentpachi (France, EU) France
Sunday, March 21, 2010, 11:42 AM PDT

Well too bad.

thanks



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.