/** Generate evolutions. */ @Override public void create() { if (!environment.isProd()) { config .serverConfigs() .forEach( (key, serverConfig) -> { String evolutionScript = generateEvolutionScript(servers.get(key)); if (evolutionScript != null) { File evolutions = environment.getFile("conf/evolutions/" + key + "/1.sql"); try { String content = ""; if (evolutions.exists()) { content = new String(Files.readAllBytes(evolutions.toPath()), "utf-8"); } if (content.isEmpty() || content.startsWith("# --- Created by Ebean DDL")) { environment.getFile("conf/evolutions/" + key).mkdirs(); if (!content.equals(evolutionScript)) { Files.write(evolutions.toPath(), evolutionScript.getBytes("utf-8")); } } } catch (IOException e) { throw new RuntimeException(e); } } }); } }
/** Initialise the Ebean servers. */ public void start() { config .serverConfigs() .forEach((key, serverConfig) -> servers.put(key, EbeanServerFactory.create(serverConfig))); }