com.liquibase.ext.changelog.FormattedMongoshChangelogRewriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-commercial-mongodb Show documentation
Show all versions of liquibase-commercial-mongodb Show documentation
Liquibase Commercial Extension for MongoDB
The newest version!
package com.liquibase.ext.changelog;
import com.datical.liquibase.ext.changelog.AbstractFormattedChangelogRewriter;
import liquibase.GlobalConfiguration;
import liquibase.Scope;
import liquibase.util.StreamUtil;
import java.io.IOException;
import java.io.InputStream;
public class FormattedMongoshChangelogRewriter extends AbstractFormattedChangelogRewriter {
@Override
protected String getSingleLineCommentOneCharacter() {
return "/";
}
@Override
protected String getSingleLineCommentSequence() {
return "//";
}
@Override
protected String getFirstLine() {
return "liquibase formatted mongo";
}
@Override
protected String getSequenceName() {
return "Mongosh";
}
@Override
public boolean supports(String path) {
try (InputStream is = Scope.getCurrentScope().getResourceAccessor().getExisting(path).openInputStream()) {
String encoding = GlobalConfiguration.OUTPUT_FILE_ENCODING.getCurrentValue();
String changelogString = StreamUtil.readStreamAsString(is, encoding);
return changelogString.toLowerCase().contains(getFirstLine());
} catch (IOException ioe) {
return false;
}
}
}