create primary keys on directly on table creation instead of a seperate operation

This commit is contained in:
wea_ondara
2022-11-27 07:58:29 +01:00
parent 1f90bc551b
commit 3e581a9e4a
9 changed files with 56 additions and 54 deletions

View File

@@ -102,7 +102,10 @@ public class MysqlMigrationOperationTranslator implements MigrationOperationTran
var f = e.build();
return "`" + f.getField() + "` " + f.getSqlType() + (f.isNotNull() ? " NOT NULL" : "");
}).collect(Collectors.joining(", "))
+ ")"); //TODO default collocation from database config or operation, field collation, primary key, constraints
+ (op.getPrimaryKey() != null
? ", PRIMARY KEY (" + op.getPrimaryKey().build().getFields().stream().map(e -> "`" + e + "`").collect(Collectors.joining(", ")) + ")"
: "")
+ ")"); //TODO default collocation from database config or operation, field collation, constraints
}
private static PreparedStatement translateAddUniqueKeyOperation(Connection connection, MigrationOperation operation) throws SQLException {