README.txt Database scripts for $DBTYPE. Follow the installation guide for instructions on setting up your database. #** Define templates to be generated **# #set( $templates = ["createdb", "200-to-210-migration", "210-to-230-migration", "230-to-240-migration", "240-to-300-migration", "300-to-310-migration"]) #** Special macro to add table column with default null **# #macro(addColumnNull $table $column $type) #if ($DBTYPE == "ORACLE") alter table $table add $column $type default null; #else alter table $table add column $column $type default null; #end #end #** Special macro to add table column with not-null restriction and default value **# #macro(addColumnNotNull $table $column $type $default) #if($DBTYPE == "MYSQL" || $DBTYPE=="HSQDB") alter table $table add column $column $type default $default not null; #elseif ($DBTYPE == "POSTGRESQL") alter table $table add column $column $type; alter table $table alter $column set default $default; update $table set $column=$default; alter table $table alter $column set not null; #elseif ($DBTYPE == "HSQLDB") alter table $table add column $column $type default $default not null; #elseif ($DBTYPE == "DERBY" || $DBTYPE == "DB2") alter table $table add column $column $type with default $default not null; #elseif ($DBTYPE == "ORACLE") alter table $table add $column $type default $default not null; #end #end #** Special macro to drop NOT NULL requirement from an 'id' column. **# #macro(dropNotNullFromTableId $table) #if($DBTYPE == "MYSQL") alter table $table drop primary key; alter table $table modify id varchar(48) null; #elseif ($DBTYPE == "POSTGRESQL") alter table $table drop constraint "${table}_pkey"; alter table $table alter column id drop not null; #elseif ($DBTYPE == "HSQLDB") alter table $table alter column id varchar(48) null; #elseif ($DBTYPE == "DERBY" || $DBTYPE == "DB2") alter table $table drop primary key; alter table $table alter column id null; #elseif ($DBTYPE == "ORACLE") alter table $table drop primary key; #end #end #** Loop through templates, generate database scripts **# #foreach ($template in $templates) #set($in = "${template}.vm") #set($out = "${template}.sql") $generator.parse($in, $out) #end