Skip to content

Commit 29cac9e

Browse files
committed
Added option to specify BTREE or HASH
1 parent ea7aa71 commit 29cac9e

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/main/java/org/javawebstack/orm/annotation/Index.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
@Target(ElementType.TYPE)
77
@Repeatable(Indices.class)
88
public @interface Index {
9+
Type type() default Type.AUTO;
910
boolean unique() default false;
1011
String id() default "";
1112
String[] value() default {};
13+
14+
enum Type {
15+
AUTO,
16+
BTREE,
17+
HASH
18+
}
1219
}

‎src/main/java/org/javawebstack/orm/migration/AutoMigrator.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ private static void migrateTable(SQL sql, TableInfo info, boolean tableExists) {
136136
StringBuilder sb = new StringBuilder("CREATE ");
137137
if (index.unique())
138138
sb.append("UNIQUE ");
139+
if (index.type() != Index.Type.AUTO)
140+
sb.append("USING ").append(index.type().name()).append(" ");
139141
sb.append("INDEX `")
140142
.append(id)
141143
.append("` ON `")

0 commit comments

Comments
 (0)