db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <tfisc...@apache.org>
Subject AW: SQL generated schema
Date Tue, 22 Nov 2005 20:34:05 GMT
Thoralf,

I have added the feature you described in SVN.
Spying on the implementation which already exists for oracle, I have used 
the tablefk template instead of adding an extra alter-table.template.

Thanks again for sharing your patch,

     Thomas


On Fri, 18 Nov 2005, Thoralf Rickert wrote:

> Hi!
>
> I think, the second approach is possible without much work. I did three things to use
ALTER TABLEs.
>
> 1. I've added a new for-loop in the sql/base/Control.vm at the end
>   of the foreach datamodel loop. This loop goes through all tables
>   and calls a new template called alter-table.vm in the desired
>   database type.
>
>   #foreach ($dataModel in $dataModels)
>    [...]
>    #foreach ($table in $database.tables)
>     $generator.parse("$basepath/alter-table.vm",$outFile,"table",$tbl)
>    #end
>   #end
>
> 2. I've created the alter-table.vm in the mysql template directory
>   (sql/base/mysql) and added the ALTER TABLE command.
>
>   #foreach ($fk in $table.ForeignKeys)
>    ALTER TABLE $table.Name add FOREIGN KEY ($fk.LocalColumnNames)
>      REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames)
>      #if ($fk.hasOnUpdate()) ON UPDATE $fk.OnUpdate #end
>      #if ($fk.hasOnDelete()) ON DELETE $fk.OnDelete #end;
>   #end
>
> 3. I've deleted the content from the /sql/base/mysql/foreignkey.vm which
>   is responsible for the foreign key creating in the CREATE TABLE
>   command.
>
> So, there is just one point to do in every DB Template. Create an empty alter-table.vm
template. That is done in 2 minutes. And if somebody has a patch for a specific database type,
he/she can change the alter-table.vm and delete the content from foreignkey.vm as I did it.
That's it.
>
> bye
> Thoralf

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message