title: ormlite createTableIfNotExists fails if table has index
body: <p>I have a simple class like this : </p>
  
  <pre><code>@DatabaseTable(tableName = "VlpTag")
  public class VlpTag implements Serializable {
  
      private static final long serialVersionUID = -4912974444196844860L;
  
      @DatabaseField(generatedId = true)
      private int id;
  
      @DatabaseField(foreign = true, columnName = "buid", canBeNull = false, foreignAutoCreate = true, foreignAutoRefresh = true)
      private VlpVirtualApp vApp;
  
      @DatabaseField
      private long lastUpdated;
  
      @DatabaseField(index=true)
      private String tagValue;
  
      @DatabaseField(dataType = DataType.ENUM_INTEGER)
      private TagType tagType;
  
      public static enum TagType {
          UUID, TAG
      };
  
      public VlpTag() {
          // needed by ormlite
      }
  }
  </code></pre>
  
  <p>Then I use TableUtils to create the table if it doesn't exists :</p>
  
  <pre><code>TableUtils.createTableIfNotExists(MySQLConnection.getInstance()
              .getConnection(), VlpTag.class);
  </code></pre>
  
  <p>If the table doesn't exist, there is not problem, although it the table exists, ORMLite raise an exception saying that the index exists :</p>
  
  <pre><code>java.sql.SQLException: SQL statement failed: CREATE INDEX `VlpTag_tagValue_idx` ON `VlpTag` ( `tagValue` )
      at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:22)
      at com.j256.ormlite.table.TableUtils.doStatements(TableUtils.java:464)
      at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:440)
      at com.j256.ormlite.table.TableUtils.createTable(TableUtils.java:220)
      at com.j256.ormlite.table.TableUtils.createTableIfNotExists(TableUtils.java:61)
      at com.banctecmtl.ca.vlp.controller.listvmupdater.DatabaseUpdater.&lt;init&gt;(DatabaseUpdater.java:47)
      at com.banctecmtl.ca.vlp.controller.listvmupdater.ListVMUpdater.&lt;init&gt;(ListVMUpdater.java:42)
      at com.banctecmtl.ca.vlp.controller.VlpController.&lt;init&gt;(VlpController.java:75)
      at com.banctecmtl.ca.vlp.view.webview.server.VlpControllerServiceImpl.init(VlpControllerServiceImpl.java:32)
      at javax.servlet.GenericServlet.init(GenericServlet.java:212)
      at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
      at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
      at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616)
      at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
      at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
      at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
      at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
      at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
      at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
      at org.mortbay.jetty.Server.doStart(Server.java:222)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
      at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
      at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
      at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068)
      at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)
      at com.google.gwt.dev.DevMode.main(DevMode.java:311)
  Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate key name 'VlpTag_tagValue_idx'
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.Util.getInstance(Util.java:386)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
      at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
      at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1362)
      at com.j256.ormlite.jdbc.JdbcCompiledStatement.runExecute(JdbcCompiledStatement.java:62)
      at com.j256.ormlite.table.TableUtils.doStatements(TableUtils.java:458)
      ... 29 more
  </code></pre>
  
  <p>This bug has already been <a href="http://sourceforge.net/tracker/?func=detail&amp;aid=3437795&amp;group_id=297653&amp;atid=1255989" rel="nofollow">reported on the bug list</a> and I was wondering it was resolved 
  beacause I have the same problem. I use MYSQL and <code>ormlite-core-4.33.jar</code>. </p>
  
  <p>Is there something I'm doing wrong here, or there is a problem with that?</p>
  
  <p>Thanks</p>