本文整理汇总了Java中liquibase.change.Change类的典型用法代码示例。如果您正苦于以下问题:Java Change类的具体用法?Java Change怎么用?Java Change使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Change类属于liquibase.change包,在下文中一共展示了Change类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createInverses
import liquibase.change.Change; //导入依赖的package包/类
@Override
protected Change[] createInverses() {
List<Change> inverses = new ArrayList<Change>();
for (ColumnConfig aColumn : getColumns()) {
if (aColumn.hasDefaultValue()) {
DropDefaultValueChange dropChange = new DropDefaultValueChange();
dropChange.setTableName(getTableName());
dropChange.setColumnName(aColumn.getName());
dropChange.setSchemaName(getSchemaName());
inverses.add(dropChange);
}
// that's the percona drop column change.
PerconaDropColumnChange inverse = new PerconaDropColumnChange();
inverse.setSchemaName(getSchemaName());
inverse.setColumnName(aColumn.getName());
inverse.setTableName(getTableName());
inverses.add(inverse);
}
return inverses.toArray(new Change[inverses.size()]);
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:24,代码来源:PerconaAddColumnChange.java
示例2: createInverses
import liquibase.change.Change; //导入依赖的package包/类
@Override
protected Change[] createInverses() {
DropForeignKeyConstraintChange dropFK = new DropForeignKeyConstraintChange();
dropFK.setBaseTableSchemaName(getExistingTableSchemaName());
dropFK.setBaseTableName(getExistingTableName());
dropFK.setConstraintName(getFinalConstraintName());
DropTableChange dropTable = new DropTableChange();
dropTable.setSchemaName(getNewTableSchemaName());
dropTable.setTableName(getNewTableName());
return new Change[]{
dropFK,
dropTable,
};
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:17,代码来源:AddLookupTableChange.java
示例3: parseAndGenerate
import liquibase.change.Change; //导入依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
liquiBase.checkLiquibaseTables(false, changeLog, new Contexts(), new LabelExpression());
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
Change change = changeSets.get(0).getChanges().get(0);
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
String expected = "DROP SYNONYM new_synonym";
assertEquals(expected, sql[0].toSql());
}
开发者ID:liquibase,项目名称:liquibase-oracle,代码行数:25,代码来源:DropSynonymTest.java
示例4: parseAndGenerate
import liquibase.change.Change; //导入依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
liquiBase.checkLiquibaseTables(false, changeLog, new Contexts(), new LabelExpression());
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
Change change = changeSets.get(0).getChanges().get(0);
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
String expected = "CREATE SYNONYM new_synonym FOR object";
assertEquals(expected, sql[0].toSql());
}
开发者ID:liquibase,项目名称:liquibase-oracle,代码行数:25,代码来源:CreateSynonymTest.java
示例5: generateSql
import liquibase.change.Change; //导入依赖的package包/类
@Override
public Sql[] generateSql(MarkChangeSetRanStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ChangeSet changeSet = statement.getChangeSet();
SqlStatement runStatement;
try {
if (statement.getExecType().equals(ChangeSet.ExecType.FAILED) || statement.getExecType().equals(ChangeSet.ExecType.SKIPPED)) {
return new Sql[0]; //don't mark
}
String tag = null;
for (Change change : changeSet.getChanges()) {
if (change instanceof TagDatabaseChange) {
TagDatabaseChange tagChange = (TagDatabaseChange) change;
tag = tagChange.getTag();
}
}
runStatement = new HiveInsertStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName())
.addColumnValue(changeSet.getId())
.addColumnValue(changeSet.getAuthor())
.addColumnValue(changeSet.getFilePath())
.addColumnValue(DateTimeUtils.getCurrentTS("yyyy-MM-dd HH:mm:ss"))
.addColumnValue(ChangeLogHistoryServiceFactory.getInstance().getChangeLogService(database).getNextSequenceValue())
.addColumnValue(statement.getExecType().value)
.addColumnValue(changeSet.generateCheckSum().toString())
.addColumnValue(changeSet.getDescription())
.addColumnValue(StringUtils.trimToEmpty(changeSet.getComments()))
.addColumnValue(tag == null ? "NULL" : tag)
.addColumnValue(ChangeLogHistoryServiceFactory.getInstance().getChangeLogService(database).getDeploymentId())
.addColumnValue(changeSet.getContexts() == null || changeSet.getContexts().isEmpty() ? null : changeSet.getContexts().toString())
.addColumnValue(changeSet.getLabels() == null || changeSet.getLabels().isEmpty() ? null : changeSet.getLabels().toString())
.addColumnValue(LiquibaseUtil.getBuildVersion());
} catch (LiquibaseException e) {
throw new UnexpectedLiquibaseException(e);
}
return SqlGeneratorFactory.getInstance().generateSql(runStatement, database);
}
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:40,代码来源:HiveMarkChangeSetRanGenerator.java
示例6: createInverses
import liquibase.change.Change; //导入依赖的package包/类
@Override
protected Change[] createInverses() {
PerconaDropIndexChange inverse = new PerconaDropIndexChange();
inverse.setIndexName(getIndexName());
inverse.setCatalogName(getCatalogName());
inverse.setSchemaName(getSchemaName());
inverse.setTableName(getTableName());
return new Change[] { inverse };
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:11,代码来源:PerconaCreateIndexChange.java
示例7: createInverses
import liquibase.change.Change; //导入依赖的package包/类
@Override
protected Change[] createInverses() {
// that's the percona drop unique constraint change
PerconaDropUniqueConstraintChange inverse = new PerconaDropUniqueConstraintChange();
inverse.setSchemaName(getSchemaName());
inverse.setTableName(getTableName());
inverse.setConstraintName(getConstraintName());
return new Change[] { inverse };
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:11,代码来源:PerconaAddUniqueConstraintChange.java
示例8: createInverses
import liquibase.change.Change; //导入依赖的package包/类
@Override
protected Change[] createInverses() {
// that's the percona drop foreign key constraint change
PerconaDropForeignKeyConstraintChange inverse = new PerconaDropForeignKeyConstraintChange();
inverse.setBaseTableSchemaName(getBaseTableSchemaName());
inverse.setBaseTableName(getBaseTableName());
inverse.setConstraintName(getConstraintName());
return new Change[] { inverse };
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:11,代码来源:PerconaAddForeignKeyConstraintChange.java
示例9: testReadLiquibaseUsePerconaFlagYAML
import liquibase.change.Change; //导入依赖的package包/类
@Test
public void testReadLiquibaseUsePerconaFlagYAML() throws Exception {
DatabaseChangeLog changelog = loadChangeLog("test-changelog.yaml");
Assert.assertEquals(2, changelog.getChangeSets().size());
ChangeSet addColumnChangeset = changelog.getChangeSets().get(1);
Change change = addColumnChangeset.getChanges().get(0);
Assert.assertEquals(PerconaAddColumnChange.class, change.getClass());
Assert.assertNotNull(((PerconaAddColumnChange)change).getUsePercona());
Assert.assertFalse(((PerconaAddColumnChange)change).getUsePercona());
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:11,代码来源:ChangeLogParserTest.java
示例10: testReadLiquibaseUsePerconaFlagXML
import liquibase.change.Change; //导入依赖的package包/类
@Ignore("The original schema doesn't allow to add arbitrary attributes to the changes")
@Test
public void testReadLiquibaseUsePerconaFlagXML() throws Exception {
DatabaseChangeLog changelog = loadChangeLog("test-changelog.xml");
Assert.assertEquals(2, changelog.getChangeSets().size());
ChangeSet addColumnChangeset = changelog.getChangeSets().get(1);
Change change = addColumnChangeset.getChanges().get(0);
Assert.assertEquals(PerconaAddColumnChange.class, change.getClass());
Assert.assertNotNull(((PerconaAddColumnChange)change).getUsePercona());
Assert.assertFalse(((PerconaAddColumnChange)change).getUsePercona());
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:12,代码来源:ChangeLogParserTest.java
示例11: testReadLiquibaseUsePerconaFlagXMLPercona
import liquibase.change.Change; //导入依赖的package包/类
@Test
public void testReadLiquibaseUsePerconaFlagXMLPercona() throws Exception {
DatabaseChangeLog changelog = loadChangeLog("test-changelog-percona.xml");
Assert.assertEquals(2, changelog.getChangeSets().size());
ChangeSet addColumnChangeset = changelog.getChangeSets().get(1);
Change change = addColumnChangeset.getChanges().get(0);
Assert.assertEquals(PerconaAddColumnChange.class, change.getClass());
Assert.assertNotNull(((PerconaAddColumnChange)change).getUsePercona());
Assert.assertFalse(((PerconaAddColumnChange)change).getUsePercona());
}
开发者ID:adangel,项目名称:liquibase-percona,代码行数:11,代码来源:ChangeLogParserTest.java
示例12: parseAndGenerate
import liquibase.change.Change; //导入依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser( changeLogFile, resourceAccessor ).parse( changeLogFile, changeLogParameters, resourceAccessor );
liquiBase.checkLiquibaseTables( true, changeLog, new Contexts() );
changeLog.validate( database );
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview1 AS select 1 as One from dual", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview2 AS select * from mytable", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview2 AS select * from mytable where rownum = 1", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview4 AS select 1 as One from dual", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview3 AS select * from mytable", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview3 AS select * from mytable where one like '%%'", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "Drop materialized view myview2" ) );
int i = 0;
for ( ChangeSet changeSet : changeSets ) {
for ( Change change : changeSet.getChanges() ) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql( change.generateStatements( database )[0], database );
if ( change instanceof CreateFlexibleViewChange ) {
for ( Sql s : sql ) {
System.out.println( "--------------------------------------------------------------------------------------------------------" );
System.out.println( "ACTUAL: " + s.toSql() );
System.out.println( "EXPECT: " + expectedQuery.get( i ) );
assertEquals( expectedQuery.get( i ), s.toSql() );
i++;
}
}
}
}
}
开发者ID:mrswadge,项目名称:liquibase-flexibleview,代码行数:41,代码来源:CreateFlexibleViewTest.java
示例13: writeBody
import liquibase.change.Change; //导入依赖的package包/类
@Override
protected void writeBody(FileWriter fileWriter, Object object, List<Change> ranChanges, List<Change> changesToRun) throws IOException, DatabaseHistoryException, DatabaseException {
Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
LoggingExecutor loggingExecutor = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), fileWriter, database);
ExecutorService.getInstance().setExecutor(database, loggingExecutor);
try {
if (changesToRun.size() == 0) {
fileWriter.append("<b>NONE</b>");
}
fileWriter.append("<code><pre>");
ChangeSet lastRunChangeSet = null;
for (Change change : changesToRun) {
ChangeSet thisChangeSet = change.getChangeSet();
if (thisChangeSet.equals(lastRunChangeSet)) {
continue;
}
lastRunChangeSet = thisChangeSet;
String anchor = thisChangeSet.toString(false).replaceAll("\\W","_");
fileWriter.append("<a name='").append(anchor).append("'/>");
try {
thisChangeSet.execute(databaseChangeLog, this.database);
} catch (MigrationFailedException e) {
fileWriter.append("EXECUTION ERROR: ").append(change.getChangeMetaData().getDescription()).append(": ").append(e.getMessage()).append("\n\n");
}
}
fileWriter.append("</pre></code>");
} finally {
ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:36,代码来源:PendingSQLWriter.java
示例14: saveStatements
import liquibase.change.Change; //导入依赖的package包/类
public void saveStatements(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException, UnsupportedChangeException, StatementNotSupportedOnDatabaseException, LiquibaseException {
SqlStatement[] statements = change.generateStatements(this);
for (SqlStatement statement : statements) {
for (Sql sql : SqlGeneratorFactory.getInstance().generateSql(statement, this)) {
writer.append(sql.toSql()).append(sql.getEndDelimiter()).append(StreamUtil.getLineSeparator()).append(StreamUtil.getLineSeparator());
}
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:9,代码来源:AbstractDatabase.java
示例15: executeRollbackStatements
import liquibase.change.Change; //导入依赖的package包/类
public void executeRollbackStatements(Change change, List<SqlVisitor> sqlVisitors) throws LiquibaseException, UnsupportedChangeException, RollbackImpossibleException {
SqlStatement[] statements = change.generateRollbackStatements(this);
List<SqlVisitor> rollbackVisitors = new ArrayList<SqlVisitor>();
if (sqlVisitors != null) {
for (SqlVisitor visitor : sqlVisitors) {
if (visitor.isApplyToRollback()) {
rollbackVisitors.add(visitor);
}
}
}
execute(statements, rollbackVisitors);
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:13,代码来源:AbstractDatabase.java
示例16: saveRollbackStatement
import liquibase.change.Change; //导入依赖的package包/类
public void saveRollbackStatement(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException, UnsupportedChangeException, RollbackImpossibleException, StatementNotSupportedOnDatabaseException, LiquibaseException {
SqlStatement[] statements = change.generateRollbackStatements(this);
for (SqlStatement statement : statements) {
for (Sql sql : SqlGeneratorFactory.getInstance().generateSql(statement, this)) {
writer.append(sql.toSql()).append(sql.getEndDelimiter()).append("\n\n");
}
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:9,代码来源:AbstractDatabase.java
示例17: generateCheckSum
import liquibase.change.Change; //导入依赖的package包/类
public CheckSum generateCheckSum() {
StringBuffer stringToMD5 = new StringBuffer();
for (Change change : getChanges()) {
stringToMD5.append(change.generateCheckSum()).append(":");
}
for (SqlVisitor visitor : this.getSqlVisitors()) {
stringToMD5.append(visitor.generateCheckSum()).append(";");
}
return CheckSum.compute(stringToMD5.toString());
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:14,代码来源:ChangeSet.java
示例18: supportsRollback
import liquibase.change.Change; //导入依赖的package包/类
public boolean supportsRollback(Database database) {
if (rollBackChanges != null && rollBackChanges.size() > 0) {
return true;
}
for (Change change : getChanges()) {
if (!change.supportsRollback(database)) {
return false;
}
}
return true;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:13,代码来源:ChangeSet.java
示例19: getDescription
import liquibase.change.Change; //导入依赖的package包/类
public String getDescription() {
List<Change> changes = getChanges();
if (changes.size() == 0) {
return "Empty";
}
StringBuffer returnString = new StringBuffer();
Class<? extends Change> lastChangeClass = null;
int changeCount = 0;
for (Change change : changes) {
if (change.getClass().equals(lastChangeClass)) {
changeCount++;
} else if (changeCount > 1) {
returnString.append(" (x").append(changeCount).append(")");
returnString.append(", ");
returnString.append(change.getChangeMetaData().getDescription());
changeCount = 1;
} else {
returnString.append(", ").append(change.getChangeMetaData().getDescription());
changeCount = 1;
}
lastChangeClass = change.getClass();
}
if (changeCount > 1) {
returnString.append(" (x").append(changeCount).append(")");
}
return returnString.toString().replaceFirst("^, ", "");
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:31,代码来源:ChangeSet.java
示例20: DBDocVisitor
import liquibase.change.Change; //导入依赖的package包/类
public DBDocVisitor(Database database) {
this.database = database;
changesByObject = new HashMap<DatabaseObject, List<Change>>();
changesByAuthor = new HashMap<String, List<Change>>();
changeLogs = new TreeSet<ChangeLogInfo>();
changesToRunByObject = new HashMap<DatabaseObject, List<Change>>();
changesToRunByAuthor = new HashMap<String, List<Change>>();
changesToRun = new ArrayList<Change>();
recentChanges = new ArrayList<Change>();
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:13,代码来源:DBDocVisitor.java
注:本文中的liquibase.change.Change类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论