diff --git a/server/src/main/java/dev/plex/storage/database/MigrationRunner.java b/server/src/main/java/dev/plex/storage/database/MigrationRunner.java index 3916c57..c9fbf67 100644 --- a/server/src/main/java/dev/plex/storage/database/MigrationRunner.java +++ b/server/src/main/java/dev/plex/storage/database/MigrationRunner.java @@ -7,6 +7,9 @@ import dev.plex.util.PlexLog; import javax.sql.DataSource; import java.io.IOException; import java.io.InputStream; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.sql.PreparedStatement; @@ -128,7 +131,7 @@ public class MigrationRunner private String readModule(PlexModule module, String resourceRoot, String version) throws SQLException { String resource = resourceRoot + "/" + storageType.dialect().migrationDirectory() + "/" + version + ".sql"; - try (InputStream stream = module.getResource(resource)) + try (InputStream stream = openModuleResource(module, resource)) { if (stream == null) { @@ -142,6 +145,32 @@ public class MigrationRunner } } + /** + * Opens a migration resource from the module's own jar. + * + *
A module class loader is parent-first with the Plex class loader as its
+ * parent, and core ships migration scripts at the same
+ * {@code db/migration/