mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1267 - DDL issue on @OneToMany @JoinTable ... extra unnecessary index created on fk column
This commit is contained in:
@@ -656,4 +656,12 @@ public class MTable {
|
||||
return draftTableName + "." + references.substring(lastDot + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the indexes on the foreign keys as they are covered by unique constraints.
|
||||
*/
|
||||
public void clearForeignKeyIndexes() {
|
||||
for (MCompoundForeignKey compoundKey : compoundKeys) {
|
||||
compoundKey.setIndexName(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
|
||||
// in the middle of rendering the create table DDL
|
||||
MTable intersectionTable = new ModelBuildIntersectionTable(ctx, p).build();
|
||||
if (p.isO2mJoinTable()) {
|
||||
intersectionTable.clearForeignKeyIndexes();
|
||||
Collection<MColumn> cols = intersectionTable.allColumns();
|
||||
if (cols.size() == 2) {
|
||||
// always the second column that we put the unique constraint on
|
||||
|
||||
Reference in New Issue
Block a user