Skip to content

Commit

Permalink
0003068: MySQL Create Table with Timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpmind-josh committed Apr 24, 2017
1 parent 4f9ba26 commit 129e50f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -319,6 +319,9 @@ protected String getSqlType(Column column) {
&& (column.getMappedTypeCode() == Types.DECIMAL || column.getMappedTypeCode() == Types.NUMERIC)) {
sqlType = "BIGINT";
}
if (column.getMappedTypeCode() == Types.TIMESTAMP && column.getScale() > 0) {
sqlType = "TIMESTAMP(" + column.getScale() + ")";
}
return sqlType;
}

Expand Down
@@ -1,5 +1,7 @@
package org.jumpmind.db.platform.mysql;

import java.sql.Types;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -22,6 +24,10 @@
import javax.sql.DataSource;

import org.apache.commons.lang.StringUtils;
import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Database;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.model.TypeMap;
import org.jumpmind.db.platform.AbstractJdbcDatabasePlatform;
import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.platform.PermissionResult;
Expand Down Expand Up @@ -132,4 +138,22 @@ public PermissionResult getCreateSymRoutinePermission() {
}
return result;
}

@Override
public void makePlatformSpecific(Database database) {
for (Table table : database.getTables()) {
for (Column column : table.getColumns()) {
try {
if (column.getMappedTypeCode() == Types.DATE
&& column.findPlatformColumn(DatabaseNamesConstants.ORACLE) != null) {
column.setMappedType(TypeMap.TIMESTAMP);
column.setMappedTypeCode(Types.TIMESTAMP);
column.setScale(6);
}
}
catch (Exception e) {}
}
}
super.makePlatformSpecific(database);
}
}

0 comments on commit 129e50f

Please sign in to comment.