use of org.flywaydb.core.internal.resource.ResourceName in project flyway by flyway.
the class SqlMigrationResolver method addMigrations.
private void addMigrations(List<ResolvedMigration> migrations, String prefix, String[] suffixes, boolean repeatable) {
ResourceNameParser resourceNameParser = new ResourceNameParser(configuration);
for (LoadableResource resource : resourceProvider.getResources(prefix, suffixes)) {
String filename = resource.getFilename();
ResourceName result = resourceNameParser.parse(filename);
if (!result.isValid() || isSqlCallback(result) || !prefix.equals(result.getPrefix())) {
continue;
}
SqlScript sqlScript = sqlScriptFactory.createSqlScript(resource, configuration.isMixed(), resourceProvider);
List<LoadableResource> resources = new ArrayList<>();
resources.add(resource);
Integer checksum = getChecksumForLoadableResource(repeatable, resources);
Integer equivalentChecksum = getEquivalentChecksumForLoadableResource(repeatable, resources);
migrations.add(new ResolvedMigrationImpl(result.getVersion(), result.getDescription(), resource.getRelativePath(), checksum, equivalentChecksum, MigrationType.SQL, resource.getAbsolutePathOnDisk(), new SqlMigrationExecutor(sqlScriptExecutorFactory, sqlScript, false, false)) {
@Override
public void validate() {
}
});
}
}
use of org.flywaydb.core.internal.resource.ResourceName in project flyway by flyway.
the class Parser method parse.
/**
* Parses this resource into a stream of statements.
*
* @param resource The resource to parse.
* @param metadata The resource's metadata.
* @return The statements.
*/
public final SqlStatementIterator parse(LoadableResource resource, SqlScriptMetadata metadata) {
PositionTracker tracker = new PositionTracker();
Recorder recorder = new Recorder();
ParserContext context = new ParserContext(getDefaultDelimiter());
String filename = resource.getFilename();
LOG.debug("Parsing " + filename + " ...");
ResourceName result = new ResourceNameParser(configuration).parse(filename);
parsingContext.updateFilenamePlaceholder(result);
PeekingReader peekingReader = new PeekingReader(new RecordingReader(recorder, new PositionTrackingReader(tracker, replacePlaceholders(new BomStrippingReader(new UnboundedReadAheadReader(new BufferedReader(resource.read(), 4096))), metadata))), supportsPeekingMultipleLines());
return new ParserSqlStatementIterator(peekingReader, resource, recorder, tracker, context);
}
Aggregations