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

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

Go to download

The MyBatis SQL mapper framework makes it easier to use a relational database with object-oriented applications. MyBatis couples objects with stored procedures or SQL statements using a XML descriptor or annotations. Simplicity is the biggest advantage of the MyBatis data mapper over object relational mapping tools.

There is a newer version: 3.5.19
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) {
    printStream.println("ID             Applied At          Description");
    printStream.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) {
      printStream.println(change);
    }
    printStream.println();
  }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy