/** * Return the content for the migration apply ddl script. */ public String getContent() { return resource.loadAsString("UTF-8"); }
/** * Read the deployment XML for the given resources. */ public static List<XmEbean> readByResourceList(List<Resource> resourceList){ try { List<XmEbean> mappings = new ArrayList<>(); for (Resource xmlMappingRes : resourceList) { try (InputStream is = new FileInputStream(xmlMappingRes.getLocationOnDisk())) { mappings.add(XmlMappingReader.read(is)); } } return mappings; } catch (IOException e) { throw new RuntimeException("Error reading ebean xml mapping", e); } } }
/** * Read all the migration resources (SQL scripts) returning true if there are versions. */ public boolean readResources() { String migrationPath = migrationConfig.getMigrationPath(); ClassLoader classLoader = migrationConfig.getClassLoader(); Scanner scanner = new Scanner(classLoader); List<Resource> resourceList = scanner.scanForResources(migrationPath, new Match(migrationConfig)); logger.debug("resources: {}", resourceList); for (Resource resource : resourceList) { String filename = resource.getFilename(); if (filename.endsWith(migrationConfig.getApplySuffix())) { int pos = filename.lastIndexOf(migrationConfig.getApplySuffix()); String mainName = filename.substring(0, pos); MigrationVersion migrationVersion = MigrationVersion.parse(mainName); LocalMigrationResource res = new LocalMigrationResource(migrationVersion, resource.getLocation(), resource); versions.add(res); } } Collections.sort(versions); return !versions.isEmpty(); }
/** * Return a programmatic JDBC migration. */ private LocalMigrationResource createJdbcMigration(Resource resource, String filename) { int pos = filename.lastIndexOf(".class"); String mainName = filename.substring(0, pos); MigrationVersion migrationVersion = MigrationVersion.parse(mainName); String className = resource.getLocation().replace('/', '.'); className = className.substring(0, className.length()-6); JdbcMigration instance = migrationConfig.getJdbcMigrationFactory().createInstance(className); return new LocalJdbcMigrationResource(migrationVersion, resource.getLocation(), instance); }
private boolean readResourcesForPath(String path) { ClassLoader classLoader = migrationConfig.getClassLoader(); Scanner scanner = new Scanner(classLoader); List<Resource> resourceList = scanner.scanForResources(path, new Match(migrationConfig)); logger.debug("resources: {}", resourceList); for (Resource resource : resourceList) { String filename = resource.getFilename(); if (filename.endsWith(migrationConfig.getApplySuffix())) { versions.add(createScriptMigration(resource, filename)); } else if (migrationConfig.getJdbcMigrationFactory() != null && filename.endsWith(".class")) { versions.add(createJdbcMigration(resource, filename)); } } Collections.sort(versions); return !versions.isEmpty(); }
/** * Read all the migration resources (SQL scripts) returning true if there are versions. */ public boolean readResources() { String migrationPath = migrationConfig.getMigrationPath(); ClassLoader classLoader = migrationConfig.getClassLoader(); Scanner scanner = new Scanner(classLoader); List<Resource> resourceList = scanner.scanForResources(migrationPath, new Match(migrationConfig)); logger.debug("resources: {}", resourceList); for (Resource resource : resourceList) { String filename = resource.getFilename(); if (filename.endsWith(migrationConfig.getApplySuffix())) { int pos = filename.lastIndexOf(migrationConfig.getApplySuffix()); String mainName = filename.substring(0, pos); MigrationVersion migrationVersion = MigrationVersion.parse(mainName); LocalMigrationResource res = new LocalMigrationResource(migrationVersion, resource.getLocation(), resource); versions.add(res); } } Collections.sort(versions); return !versions.isEmpty(); }
/** * Create a script based migration. */ private LocalMigrationResource createScriptMigration(Resource resource, String filename) { int pos = filename.lastIndexOf(migrationConfig.getApplySuffix()); String mainName = filename.substring(0, pos); MigrationVersion migrationVersion = MigrationVersion.parse(mainName); return new LocalDdlMigrationResource(migrationVersion, resource.getLocation(), resource); }
/** * Return the content for the migration apply ddl script. */ public String getContent() { return resource.loadAsString("UTF-8"); }
/** * Read the deployment XML for the given resources. */ public static List<XmEbean> readByResourceList(List<Resource> resourceList){ try { List<XmEbean> mappings = new ArrayList<>(); for (Resource xmlMappingRes : resourceList) { try (InputStream is = new FileInputStream(xmlMappingRes.getLocationOnDisk())) { mappings.add(XmlMappingReader.read(is)); } } return mappings; } catch (IOException e) { throw new RuntimeException("Error reading ebean xml mapping", e); } } }
/** * Return the content for the migration apply ddl script. */ public String getContent() { return resource.loadAsString("UTF-8"); }