org.apache.ibatis.migration.commands.StatusCommand Maven / Gradle / Ivy
package org.apache.ibatis.migration.commands;
import org.apache.ibatis.migration.Change;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class StatusCommand extends BaseCommand {
public StatusCommand(File repository, String environment, boolean force) {
super(repository, environment, force);
}
public void execute(String... params) {
out.println("ID Applied At Description");
out.println(horizontalLine("", 80));
List merged = new ArrayList();
List migrations = getMigrations();
if (changelogExists()) {
List changelog = getChangelog();
for (Change change : migrations) {
int index = changelog.indexOf(change);
if (index > -1) {
merged.add(changelog.get(index));
} else {
merged.add(change);
}
}
Collections.sort(merged);
} else {
merged.addAll(migrations);
}
for (Change change : merged) {
out.println(change);
}
out.println();
}
}