title: How to programmatically create a MySQL index with limited length using JPA?
body: <p>Similar to <a href="https://stackoverflow.com/questions/3405229/specifying-an-index-non-unique-key-using-jpa">here</a> I'm annotating my class with </p>
  
  <pre><code>@Table(indexes = {@Index(columnList = "name")}) 
  </code></pre>
  
  <p>which attempts to create a non-unique index with the maximum length of the <code>varchar</code> column. Unfortunately that's not possible because it's a <code>varchar(255)</code> column of type <code>utf8mb4</code>. phpMyAdmin added <code>KEY '...' (name(191))</code> by clicking on the respective buttons in the UI, so at least my software runs efficient queries now. </p>
  
  <p>Now I was wondering if it's possible to have my Java class auto-generate the index with limited length upon creating the database schema? The code builds on <code>spring-boot-starter-data-jpa:1.4.2.RELEASE</code>.</p>