Package liquibase

Examples of liquibase.Liquibase


            }
          };
          database.setConnection(jdbcConnection);
        }

        Liquibase liq = new Liquibase("migrations.xml", accessor, database);
        liq.update("prod");
      } finally {
        if (connection != null) {
          connection.close();
        }
      }
View Full Code Here


    ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader());
    try (Connection connection = ds.getConnection()) {
      JdbcConnection jdbcConnection = new JdbcConnection(connection);
      Database db = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(jdbcConnection);

      Liquibase liquiBase = new Liquibase(CHANGELOG_FILE, resourceAccessor, db);
      liquiBase.update(STAGE);
    } catch (SQLException | LiquibaseException e) {
    }

  }
View Full Code Here

          ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
          if (dbType == DbType.DERBY || dbType == DbType.H2) {
            resourceAccessor = new ResourceAccessorFilter(resourceAccessor);
          }
         
          Liquibase liquibase = new Liquibase(changeLogResourceName, resourceAccessor, db);
          liquibase.update((String)null);
        } catch (Exception ex) {
          throw new JuRuntimeException("Couldn't run Liquibase Update %s", ex, changeLogResourceName);
        }
      }
    });
View Full Code Here

            throw new IllegalArgumentException("database.migrationFile must be set in order to run database migration.");
        }
        try {
            UrsusJDBCDataSource ursusJDBCDataSource = new UrsusJDBCDataSource(ursusJDBCConfiguration);
            Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(ursusJDBCDataSource.getConnection()));
            Liquibase liquibase = new Liquibase(migrationFile, new ClassLoaderResourceAccessor(), database);

            Liquibase_Command liquibaseCommand = Liquibase_Command.valueOf(command.toLowerCase());

            if (liquibaseCommand.equals(Liquibase_Command.dropall))
                liquibase.dropAll();
            else if (liquibaseCommand.equals(Liquibase_Command.update))
                liquibase.update(null);

        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

    @Override
    public void runLiquibaseCommand(UrsusJDBCConfiguration.Database ursusJDBCConfiguration, String command) {
        try {
            UrsusJDBCDataSource ursusJDBCDataSource = new UrsusJDBCDataSource(ursusJDBCConfiguration);
            Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(ursusJDBCDataSource.getConnection()));
            Liquibase liquibase = new Liquibase(ursusJDBCConfiguration.getMigrationFile(), new ClassLoaderResourceAccessor(), database);

            Liquibase_Command liquibaseCommand = Liquibase_Command.valueOf(command.toLowerCase());

            if (liquibaseCommand.equals(Liquibase_Command.dropall))
                liquibase.dropAll();
            else if (liquibaseCommand.equals(Liquibase_Command.update))
                liquibase.update(null);

        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

        statement.executeUpdate("use zanata_unit_test");

        Database database = DatabaseFactory.getInstance()
                .findCorrectDatabaseImplementation(new JdbcConnection(conn));

        Liquibase liquibase = new Liquibase("db/db.changelog.xml",
                new ClassLoaderResourceAccessor(), database);
        liquibase.update(null);
    }
View Full Code Here

    @Override
    public void update(Connection connection) {
        logger.debug("Starting database update");

        try {
            Liquibase liquibase = getLiquibase(connection);

            List<ChangeSet> changeSets = liquibase.listUnrunChangeSets((Contexts) null);
            if (!changeSets.isEmpty()) {
                if (changeSets.get(0).getId().equals(FIRST_VERSION)) {
                    Statement statement = connection.createStatement();
                    try {
                        statement.executeQuery("SELECT id FROM REALM");

                        logger.infov("Updating database from {0} to {1}", FIRST_VERSION, changeSets.get(changeSets.size() - 1).getId());
                        liquibase.markNextChangeSetRan((Contexts) null);
                    } catch (SQLException e) {
                        logger.info("Initializing database schema");
                    }
                } else {
                    if (logger.isDebugEnabled()) {
                        List<RanChangeSet> ranChangeSets = liquibase.getDatabase().getRanChangeSetList();
                        logger.debugv("Updating database from {0} to {1}", ranChangeSets.get(ranChangeSets.size() - 1).getId(), changeSets.get(changeSets.size() - 1).getId());
                    } else {
                        logger.infov("Updating database");
                    }
                }

                liquibase.update((Contexts) null);
            }
        } catch (Exception e) {
            throw new RuntimeException("Failed to update database", e);
        }
        logger.debug("Completed database update");
View Full Code Here

    }

    @Override
    public void validate(Connection connection) {
        try {
            Liquibase liquibase = getLiquibase(connection);

            liquibase.validate();
        } catch (Exception e) {
            throw new RuntimeException("Failed to validate database", e);
        }
    }
View Full Code Here

            sl.getPackages().remove("liquibase.sdk");
        }

        LogFactory.setInstance(new LogWrapper());
        Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
        return new Liquibase(CHANGELOG, new ClassLoaderResourceAccessor(getClass().getClassLoader()), database);
    }
View Full Code Here

  }

  @Override
  protected Liquibase createLiquibase(ResourceAccessor fo, Database db)
      throws MojoExecutionException {
    Liquibase liquibase = super.createLiquibase(fo, db);

    // Setup the output file writer
    try {
      if (!migrationSqlOutputFile.exists()) {
        // Ensure the parent directories exist
View Full Code Here

TOP

Related Classes of liquibase.Liquibase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.