#**
 510-to-520-migration.vm: Velocity template that generates vendor-specific database scripts

 DON'T RUN THIS, IT'S NOT A DATABASE CREATION SCRIPT!!!
 **#

#**
 PostgreSQL respects original not null attribute.
 **#
#macro(expandTimestamp $tableName $columnName)
#if($db.DBTYPE == "MYSQL" || $db.DBTYPE == "MSSQL")
#alterColumnType($tableName $columnName 'datetime(3)')
#elseif ($db.DBTYPE == "ORACLE" || $db.DBTYPE == "DB2" || $db.DBTYPE == "HSQLDB")
#alterColumnType($tableName $columnName 'timestamp(3)')
#elseif ($db.DBTYPE == "POSTGRESQL")
#alterColumnType($tableName $columnName 'timestamp(3) with time zone')
#end
#end

#macro(expandTimestampNotNull $tableName $columnName)
#if($db.DBTYPE == "MYSQL" || $db.DBTYPE == "MSSQL")
#alterColumnType($tableName $columnName 'datetime(3) not null')
#elseif ($db.DBTYPE == "ORACLE" || $db.DBTYPE == "DB2" || $db.DBTYPE == "HSQLDB")
#alterColumnType($tableName $columnName 'timestamp(3) not null')
#elseif ($db.DBTYPE == "POSTGRESQL")
#alterColumnType($tableName $columnName 'timestamp(3) with time zone')
#end
#end

-- Adjusting precision of datetime or timestamp columns
-- Not affects for Derby

#expandTimestampNotNull('pingqueueentry' 'entrytime')
#expandTimestamp('pingtarget' 'lastsuccess')
#expandTimestamp('rag_entry' 'updated')
#expandTimestampNotNull('rag_entry' 'published')
#expandTimestamp('rag_subscription' 'last_updated')
#expandTimestamp('roller_audit_log' 'change_time')
#expandTimestampNotNull('roller_comment' 'posttime')
#expandTimestampNotNull('roller_mediafile' 'date_uploaded')
#expandTimestamp('roller_mediafile' 'last_updated')
#expandTimestampNotNull('roller_oauthaccessor' 'created')
#expandTimestampNotNull('roller_oauthaccessor' 'updated')
#expandTimestampNotNull('roller_permission' 'datecreated')
#expandTimestamp('roller_tasklock' 'timeacquired')
#expandTimestamp('roller_tasklock' 'lastrun')
#expandTimestampNotNull('roller_user' 'datecreated')
#expandTimestampNotNull('roller_weblogentrytag' 'time')
#expandTimestampNotNull('roller_weblogentrytagagg' 'lastused')
#expandTimestampNotNull('weblog' 'datecreated')
#expandTimestamp('weblog' 'lastmodified')
#expandTimestampNotNull('weblog_custom_template' 'updatetime')
#expandTimestamp('weblogentry' 'pubtime')
#expandTimestampNotNull('weblogentry' 'updatetime')
