当前位置: 首页>>代码示例>>Java>>正文


Java MigrationLoader类代码示例

本文整理汇总了Java中org.apache.ibatis.migration.MigrationLoader的典型用法代码示例。如果您正苦于以下问题:Java MigrationLoader类的具体用法?Java MigrationLoader怎么用?Java MigrationLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MigrationLoader类属于org.apache.ibatis.migration包,在下文中一共展示了MigrationLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNoMigrationNecessary

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
@Test
public void testNoMigrationNecessary() throws Exception {
  MigrationLoader loader = new JavaMigrationLoader(
      "org.apache.aurora.scheduler.storage.db.testmigration");
  Injector injector = createMigrationInjector(loader);

  MigrationManager migrationManager = injector.getInstance(MigrationManager.class);

  migrationManager.migrate();

  SqlSessionFactory sqlSessionFactory = injector.getInstance(SqlSessionFactory.class);
  assertMigrationComplete(sqlSessionFactory, loader);

  // Run the migration a second time, no changes should be made.
  migrationManager.migrate();
  assertMigrationComplete(sqlSessionFactory, loader);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:MigrationManagerImplIT.java

示例2: testRollback

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
@Test
public void testRollback() throws Exception {
  // Run a normal migration which will apply one the change found in the testmigration package.
  MigrationLoader loader = new JavaMigrationLoader(
      "org.apache.aurora.scheduler.storage.db.testmigration");
  Injector injector = createMigrationInjector(loader);

  MigrationManager migrationManager = injector.getInstance(MigrationManager.class);

  migrationManager.migrate();

  // Now we intentionally pass a reference to a non-existent package to ensure that no migrations
  // are found. As such a rollback is expected to be detected and a downgrade be performed.
  MigrationLoader rollbackLoader = new JavaMigrationLoader(
      "org.apache.aurora.scheduler.storage.db.nomigrations");
  Injector rollbackInjector = createMigrationInjector(rollbackLoader);
  MigrationManager rollbackManager = rollbackInjector.getInstance(MigrationManager.class);

  rollbackManager.migrate();

  assertRollbackComplete(rollbackInjector.getInstance(SqlSessionFactory.class));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:23,代码来源:MigrationManagerImplIT.java

示例3: configure

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
@Override
protected void configure() {
  bind(MigrationLoader.class).toInstance(migrationLoader);

  bind(MigrationManager.class).to(MigrationManagerImpl.class);
  expose(MigrationManager.class);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:DbModule.java

示例4: assertMigrationComplete

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
/**
 * Ensure all changes have been applied and their downgrade scripts stored appropriately.
 *
 * @param sqlSessionFactory The sql session factory.
 * @param loader A migration loader.
 * @throws Exception If the changes were not applied properly.
 */
private void assertMigrationComplete(
    SqlSessionFactory sqlSessionFactory,
    MigrationLoader loader) throws Exception {

  try (SqlSession session = sqlSessionFactory.openSession()) {
    MigrationMapper mapper = session.getMapper(MigrationMapper.class);

    List<MigrationChangelogEntry> appliedChanges = mapper.selectAll();

    for (Change change : loader.getMigrations()) {
      Optional<MigrationChangelogEntry> appliedChange = appliedChanges
          .stream()
          .filter(c -> c.getId().equals(change.getId()))
          .findFirst();

      assertTrue(appliedChange.isPresent());
      assertEquals(
          CharStreams.toString(loader.getScriptReader(change, true /* undo */)),
          appliedChange.get().getDowngradeScript());
    }

    // As long as the tables exist, neither of these statements should fail.
    try (Connection c = session.getConnection()) {
      try (PreparedStatement select = c.prepareStatement("SELECT * FROM V001_test_table")) {
        select.execute();
      }
      try (PreparedStatement select = c.prepareStatement("SELECT * FROM V002_test_table2")) {
        select.execute();
      }
    }
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:40,代码来源:MigrationManagerImplIT.java

示例5: testMigrate

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
@Test
public void testMigrate() throws Exception {
  MigrationLoader loader = new JavaMigrationLoader(
      "org.apache.aurora.scheduler.storage.db.testmigration");
  Injector injector = createMigrationInjector(loader);

  injector.getInstance(MigrationManager.class).migrate();
  assertMigrationComplete(injector.getInstance(SqlSessionFactory.class), loader);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:10,代码来源:MigrationManagerImplIT.java

示例6: getMigrationLoader

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
protected MigrationLoader getMigrationLoader() {
  Environment env = environment();
  MigrationLoader migrationLoader = null;
  for (FileMigrationLoaderFactory factory : ServiceLoader.load(FileMigrationLoaderFactory.class)) {
    if (migrationLoader != null) {
      throw new MigrationException("Found multiple implementations of FileMigrationLoaderFactory via SPI.");
    }
    migrationLoader = factory.create(paths, env);
  }
  return migrationLoader != null ? migrationLoader
      : new FileMigrationLoader(paths.getScriptPath(), env.getScriptCharset(), env.getVariables());
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:13,代码来源:BaseCommand.java

示例7: getPendingChanges

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
private List<Change> getPendingChanges(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader,
    DatabaseOperationOption option) {
  List<Change> pending = new ArrayList<Change>();
  List<Change> migrations = migrationsLoader.getMigrations();
  List<Change> changelog = getChangelog(connectionProvider, option);
  for (Change change : migrations) {
    int index = changelog.indexOf(change);
    if (index < 0) {
      pending.add(change);
    }
  }
  Collections.sort(pending);
  return pending;
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:15,代码来源:PendingOperation.java

示例8: operate

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
public Object operate(
ConnectionProvider connectionProvider,
MigrationLoader migrationsLoader,
DatabaseOperationOption option,
PrintStream printStream);
 
开发者ID:Bessonov,项目名称:mybatis-migrations-spring-boot-autoconfigure,代码行数:6,代码来源:Operator.java

示例9: MigrationManagerModule

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
public MigrationManagerModule(MigrationLoader migrationLoader) {
  this.migrationLoader = requireNonNull(migrationLoader);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:4,代码来源:DbModule.java

示例10: MigrationManagerImpl

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
@Inject
MigrationManagerImpl(SqlSessionFactory sqlSessionFactory, MigrationLoader migrationLoader) {
  this.sqlSessionFactory = requireNonNull(sqlSessionFactory);
  this.migrationLoader = requireNonNull(migrationLoader);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:6,代码来源:MigrationManagerImpl.java

示例11: createMigrationInjector

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
private Injector createMigrationInjector(MigrationLoader migrationLoader) {
  return DbUtil.createStorageInjector(
      testModuleWithWorkQueue(),
      new DbModule.MigrationManagerModule(migrationLoader));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:6,代码来源:MigrationManagerImplIT.java

示例12: operate

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
public VersionOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader,
    DatabaseOperationOption option, PrintStream printStream) {
  return operate(connectionProvider, migrationsLoader, option, printStream, null, null);
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:5,代码来源:VersionOperation.java

示例13: ensureVersionExists

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
private void ensureVersionExists(MigrationLoader migrationsLoader) {
  List<Change> migrations = migrationsLoader.getMigrations();
  if (!migrations.contains(new Change(version))) {
    throw new MigrationException("A migration for the specified version number does not exist.");
  }
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:7,代码来源:VersionOperation.java

示例14: operate

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
public DownOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader,
    DatabaseOperationOption option, PrintStream printStream) {
  return operate(connectionProvider, migrationsLoader, option, printStream, null);
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:5,代码来源:DownOperation.java

示例15: operate

import org.apache.ibatis.migration.MigrationLoader; //导入依赖的package包/类
public UpOperation operate(ConnectionProvider connectionProvider, MigrationLoader migrationsLoader,
    DatabaseOperationOption option, PrintStream printStream) {
  return operate(connectionProvider, migrationsLoader, option, printStream, null);
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:5,代码来源:UpOperation.java


注:本文中的org.apache.ibatis.migration.MigrationLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。