Repository: javers/javers
Issue: Again: MySQL error: Specified key was too long; max key length is 767 bytes

#455  is back in 3.6.0 (or earlier?) affecting mysql <= 4.6..

mysql <= 4.6 has a max key length of 767 bytes (whereas >= 4.7 has a limit of 3072 bytes)

```
Caused by: org.polyjdbc.core.exception.SchemaManagerException: [DDL_ERROR] Failed to run DDL:
CREATE INDEX jv_commit_property_property_name_property_value_idx ON jv_commit_property(property_name,property_value(200))
    at org.polyjdbc.core.schema.SchemaManagerImpl.ddl(SchemaManagerImpl.java:91)
    at org.polyjdbc.core.schema.SchemaManagerImpl.create(SchemaManagerImpl.java:52)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
```


The property value index has a length of 200 [here](https://github.com/javers/javers/blob/master/javers-persistence-sql/src/main/java/org/javers/repository/sql/schema/FixedSchemaFactory.java#L124). Should it be 191 instead?

```java
    RelationBuilder relationBuilder = schema.addRelation(tableName.nameWithSchema());
        relationBuilder
            .primaryKey(tableName.localName() + "_pk").using(COMMIT_PROPERTY_COMMIT_FK, COMMIT_PROPERTY_NAME).and()
            .withAttribute().string(COMMIT_PROPERTY_NAME).withMaxLength(190).and() /// <-------
            .withAttribute().string(COMMIT_PROPERTY_VALUE).withMaxLength(600).and(); /// <------
        foreignKey(tableName, COMMIT_PROPERTY_COMMIT_FK, getCommitTableNameWithSchema(), COMMIT_PK, relationBuilder);
        relationBuilder.build();

        columnsIndex(tableName, schema, COMMIT_PROPERTY_COMMIT_FK);

        // Add index prefix length for MySql
        if (dialect instanceof MysqlDialect) {
            columnsIndex(tableName, schema, new IndexedCols(
                    new String[]{COMMIT_PROPERTY_NAME, COMMIT_PROPERTY_VALUE},
                    new int[]{0, 200})); // <--------------
        }
        else {
            columnsIndex(tableName, schema, COMMIT_PROPERTY_NAME, COMMIT_PROPERTY_VALUE);
        }
```

1. The col COMMIT_PROPERTY_NAME has max length of 190, and a prefix length of 0 for the index
2. The col COMMIT_PROPERTY_VALUE has a max length of 600, and a prefix length of 200 for the index.

Why is the prefix length 0 for PROPERTY_NAME? This effectively makes the index useless? Or does 0 mean it indexes the entire length.

But for COMMIT_PROPERTY_VALUE the maximum prefix length is  `767 / 4 = 191` in mysql 4.6 and `3072 / 4 = 768` in mysql 4.7


Changed files:
javers-persistence-sql/src/main/java/org/javers/repository/sql/schema/FixedSchemaFactory.java

diff --git a/javers-persistence-sql/src/main/java/org/javers/repository/sql/schema/FixedSchemaFactory.java b/javers-persistence-sql/src/main/java/org/javers/repository/sql/schema/FixedSchemaFactory.java
index f3d77fc0..354ab67b 100644
--- a/javers-persistence-sql/src/main/java/org/javers/repository/sql/schema/FixedSchemaFactory.java
+++ b/javers-persistence-sql/src/main/java/org/javers/repository/sql/schema/FixedSchemaFactory.java
@@ -16,6 +16,7 @@ import java.util.TreeMap;
  * @author bartosz walacik
  */
 public class FixedSchemaFactory extends SchemaNameAware {
+    private static final int MAX_INDEX_KEY_LEN_IN_MYSQL = 191;
 
     public static final String GLOBAL_ID_TABLE_NAME = "jv_global_id";
     public static final String GLOBAL_ID_PK =         "global_id_pk";
@@ -110,7 +111,7 @@ public class FixedSchemaFactory extends SchemaNameAware {
         RelationBuilder relationBuilder = schema.addRelation(tableName.nameWithSchema());
         relationBuilder
             .primaryKey(tableName.localName() + "_pk").using(COMMIT_PROPERTY_COMMIT_FK, COMMIT_PROPERTY_NAME).and()
-            .withAttribute().string(COMMIT_PROPERTY_NAME).withMaxLength(190).and()
+            .withAttribute().string(COMMIT_PROPERTY_NAME).withMaxLength(MAX_INDEX_KEY_LEN_IN_MYSQL).and()
             .withAttribute().string(COMMIT_PROPERTY_VALUE).withMaxLength(600).and();
         foreignKey(tableName, COMMIT_PROPERTY_COMMIT_FK, getCommitTableNameWithSchema(), COMMIT_PK, relationBuilder);
         relationBuilder.build();
@@ -121,7 +122,7 @@ public class FixedSchemaFactory extends SchemaNameAware {
         if (dialect instanceof MysqlDialect) {
             columnsIndex(tableName, schema, new IndexedCols(
                     new String[]{COMMIT_PROPERTY_NAME, COMMIT_PROPERTY_VALUE},
-                    new int[]{0, 200}));
+                    new int[]{0, MAX_INDEX_KEY_LEN_IN_MYSQL}));
         }
         else {
             columnsIndex(tableName, schema, COMMIT_PROPERTY_NAME, COMMIT_PROPERTY_VALUE);
@@ -136,7 +137,7 @@ public class FixedSchemaFactory extends SchemaNameAware {
         RelationBuilder relationBuilder = schema.addRelation(tableName.nameWithSchema());
         primaryKey(GLOBAL_ID_PK, schema,relationBuilder);
         relationBuilder
-                .withAttribute().string(GLOBAL_ID_LOCAL_ID).withMaxLength(190).and()
+                .withAttribute().string(GLOBAL_ID_LOCAL_ID).withMaxLength(MAX_INDEX_KEY_LEN_IN_MYSQL).and()
                 .withAttribute().string(GLOBAL_ID_FRAGMENT).withMaxLength(200).and()
                 .withAttribute().string(GLOBAL_ID_TYPE_NAME).withMaxLength(200).and();
         foreignKey(tableName, GLOBAL_ID_OWNER_ID_FK, getGlobalIdTableNameWithSchema(), GLOBAL_ID_PK, relationBuilder);