/** * {@inheritDoc} */ @Override public Collection<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> resolvedMigrations = Lists.newArrayList(); ScriptInfo info = migration.generate(); if (info != null) { ResolvedMigrationImpl migration = new ResolvedMigrationImpl(); migration.setVersion(MigrationVersion.fromVersion(info.getRevision())); migration.setDescription(info.getDescription()); migration.setScript(info.getRevision() + "__" + toUnderScore(info.getDescription()) + ".sql"); migration.setChecksum(calculateChecksum("-- " + info.getRevision() + "\r\n" + info.getApplyDdl())); migration.setType(MigrationType.SQL); migration.setExecutor(new SqlMigrationExecutor(info)); resolvedMigrations.add(migration); } return resolvedMigrations; }
public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<ResolvedMigration>(); Resource[] resources = scanner.scanForResources(location, shellMigrationPrefix, new String[] {shellMigrationSuffix}); for (Resource resource : resources) { ResolvedMigrationImpl resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new ShellMigrationExecutor(resource)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; }
@Override public Collection<ResolvedMigration> resolveMigrations() { SqlMigrationResolver delegate = new SqlMigrationResolver(this.dbSupport, null, getLocation(), getPlaceholderReplacer(), getEncoding(), getSqlMigrationPrefix(), flyway.getSqlMigrationSeparator(), getSqlMigrationSuffix()); Collection<ResolvedMigration> resolvedMigrations = delegate.resolveMigrations(); for (ResolvedMigration migration : resolvedMigrations) { ((ResolvedMigrationImpl) migration).setType(MigrationType.CUSTOM); } return resolvedMigrations; }
/** * Extracts the migration info for this resource. * * @param resource The resource to analyse. * @return The migration info. */ private ResolvedMigrationImpl extractMigrationInfo(Resource resource) { ResolvedMigrationImpl migration = new ResolvedMigrationImpl(); Pair<MigrationVersion, String> info = MigrationInfoHelper.extractVersionAndDescription(resource.getFilename(), shellMigrationPrefix, shellMigrationSeparator, new String [] {shellMigrationSuffix}, false); migration.setVersion(info.getLeft()); migration.setDescription(info.getRight()); migration.setScript(extractScriptName(resource)); byte [] migrationScriptAsBytes = null; try { migrationScriptAsBytes = IOUtils.toByteArray(new FileInputStream(resource.getLocation())); } catch (Exception e) { throw new ShellMigrationException(String.format("Failed to read the migration script : %s", resource.getLocation()), e); } migration.setChecksum(calculateChecksum(migrationScriptAsBytes)); migration.setType(MigrationType.CUSTOM); return migration; }
public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<ResolvedMigration>(); Resource[] resources = scanner.scanForResources(location, shellMigrationPrefix, new String[] {shellMigrationSuffix}); for (Resource resource : resources) { ResolvedMigrationImpl resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new ShellMigrationExecutor(resource)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; }
/** * Extracts the migration info for this resource. * * @param resource The resource to analyse. * @return The migration info. */ private ResolvedMigrationImpl extractMigrationInfo(Resource resource) { ResolvedMigrationImpl migration = new ResolvedMigrationImpl(); Pair<MigrationVersion, String> info = MigrationInfoHelper.extractVersionAndDescription(resource.getFilename(), shellMigrationPrefix, shellMigrationSeparator, new String [] {shellMigrationSuffix}, false); migration.setVersion(info.getLeft()); migration.setDescription(info.getRight()); migration.setScript(extractScriptName(resource)); byte [] migrationScriptAsBytes = null; try { migrationScriptAsBytes = IOUtils.toByteArray(new FileInputStream(resource.getLocation())); } catch (Exception e) { throw new ShellMigrationException(String.format("Failed to read the migration script : %s", resource.getLocation()), e); } migration.setChecksum(calculateChecksum(migrationScriptAsBytes)); migration.setType(MigrationType.CUSTOM); return migration; }