All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.ibatis.migration.commands.StatusCommand Maven / Gradle / Ivy

There is a newer version: 3.0-beta-10
Show newest version
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();
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy