For now let's worry about the case where each table has one serial column:
drop sequence User_id_seq;
drop table User;
CREATE TABLE User
(
id serial,
...
primary key(id)
);
now the drop template for this table would be:
drop sequence $table_$serial_seq;
drop table $table;
(I had to add a token separator for Utils.stringSubstitution to work,
e.g. drop sequence $table#_$serial#_seq;)
however, if id was not serial, then the drop template
would only be:
drop table $table;
So that's why I proposed the drop_seq template. It only works for
table that have one serial/autoincrement column.
Perhaps the solution might be to use webmacro/velocity templates for
the sql generation for each database. Then you could put all the columns
in the context and the template could test it:
#foreach $col in columns {
#if $col.isAutoIncrement() {
drop sequence $table;_$col.Name();_seq;;
}
}
drop $table;
#include table-sql.wm
In any case, please let me know how I can help get the right sql generated
for postgres.
mike
>
> On Tue, 31 Oct 2000, Mike Haberman wrote:
>
> > Right. But there's no easy way to figure out which column is
> > serial. Since the db/* files are simple text substition only,
> > you are unable to grab the serial columns to drop them. I must
> > be missing something, if you can already do this with the given
> > drop template.
>
> Can you send me what your actual SQL looks like?
>
> I would rather add some sort of extension mechanism
> via the XML for special cases. We can probably figure
> something out :-)
>
> jvz.
>
>
>
> ------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?: [EMAIL PROTECTED]
>
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]