From 2870b0e9bca3fc1c3ea443dd7418176126346fa6 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 1 Apr 2011 04:48:12 +0100 Subject: [PATCH] DDL generation methods By: Dinnerbone --- .../java/org/bukkit/plugin/java/JavaPlugin.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index 8f224a33e2..d112bfe42b 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -5,6 +5,8 @@ import com.avaje.ebean.EbeanServer; import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.config.DataSourceConfig; import com.avaje.ebean.config.ServerConfig; +import com.avaje.ebeaninternal.api.SpiEbeanServer; +import com.avaje.ebeaninternal.server.ddl.DdlGenerator; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -241,4 +243,18 @@ public abstract class JavaPlugin implements Plugin { public EbeanServer getDatabase() { return ebean; } + + protected void installDDL() { + SpiEbeanServer serv = (SpiEbeanServer)getDatabase(); + DdlGenerator gen = serv.getDdlGenerator(); + + gen.runScript(false, gen.generateCreateDdl()); + } + + protected void removeDDL() { + SpiEbeanServer serv = (SpiEbeanServer)getDatabase(); + DdlGenerator gen = serv.getDdlGenerator(); + + gen.runScript(true, gen.generateDropDdl()); + } }