use of liquibase.changelog.ChangeSet in project liquibase by liquibase.
the class ValidatingVisitorTest method setup.
@Before
public void setup() {
changeSet1 = new ChangeSet("1", "testAuthor", false, false, "path/changelog", null, null, null);
changeSet2 = new ChangeSet("2", "testAuthor", false, false, "path/changelog", null, null, null);
}
use of liquibase.changelog.ChangeSet in project liquibase by liquibase.
the class AbstractIntegrationTest method testGenerateChangeLogWithNoChanges.
@Test
public void testGenerateChangeLogWithNoChanges() throws Exception {
assumeNotNull(this.getDatabase());
runCompleteChangeLog();
DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(database, database, new CompareControl());
DiffToChangeLog changeLogWriter = new DiffToChangeLog(diffResult, new DiffOutputControl(false, false, false, null));
List<ChangeSet> changeSets = changeLogWriter.generateChangeSets();
assertEquals("generating two change logs without any changes in between should result in an empty generated " + "differential change set.", 0, changeSets.size());
}
use of liquibase.changelog.ChangeSet in project liquibase by liquibase.
the class MarkChangeSetRanExecuteTest method generateSql_insert.
@Test
public void generateSql_insert() throws Exception {
ChangeLogHistoryServiceFactory.getInstance().resetAll();
this.statementUnderTest = new MarkChangeSetRanStatement(new ChangeSet("a", "b", false, false, "c", "e", "f", null), ChangeSet.ExecType.EXECUTED);
String version = StringUtil.limitSize(LiquibaseUtil.getBuildVersion().replaceAll("SNAPSHOT", "SNP").replaceAll("beta", "b").replaceAll("alpha", "a"), 20);
assertCorrect("insert into [databasechangelog] ([id], [author], [filename], [dateexecuted], " + "[orderexecuted], [md5sum], [description], [comments], [exectype], [contexts], [labels], " + "[liquibase], [deployment_id]) values ('a', 'b', 'c', getdate(), 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", MSSQLDatabase.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', systimestamp, 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', " + "'executed', 'e', null, '" + version + "', null)", OracleDatabase.class);
assertCorrect("insert into [databasechangelog] ([id], [author], [filename], [dateexecuted], " + "[orderexecuted], [md5sum], [description], [comments], [exectype], [contexts], [labels], " + "[liquibase], [deployment_id]) values ('a', 'b', 'c', getdate(), 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", SybaseDatabase.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', " + "current year to fraction(5), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', " + "'executed', " + "'e', null, '" + version + "', null)", InformixDatabase.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', current timestamp, 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", DB2Database.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', current_timestamp, 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", FirebirdDatabase.class, Firebird3Database.class, DerbyDatabase.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', now, 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", HsqlDatabase.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', now(), 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", SybaseASADatabase.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, `description`, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', now(), 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", MySQLDatabase.class, MariaDBDatabase.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', now(), 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", PostgresDatabase.class, H2Database.class, CockroachDatabase.class, EnterpriseDBDatabase.class);
assertCorrect("insert into databasechangelog (id, author, filename, dateexecuted, orderexecuted, " + "md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) values " + "('a', 'b', 'c', date('now'), 1, " + "'8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, '" + version + "'," + " null)", Ingres9Database.class);
assertCorrectOnRest("insert into databasechangelog (id, author, filename, dateexecuted, " + "orderexecuted, md5sum, description, comments, exectype, contexts, labels, liquibase, deployment_id) " + "values ('a', 'b', 'c', " + "current timestamp, 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'executed', 'e', null, " + "'" + version + "', null)");
}
use of liquibase.changelog.ChangeSet in project liquibase by liquibase.
the class OracleIntegrationTest method sqlplusChangelog.
@Test
public void sqlplusChangelog() throws Exception {
Database database = this.getDatabase();
assumeNotNull(database);
Liquibase liquibase = createLiquibase(this.customExecutorChangeLog);
clearDatabase();
//
// Add a visitor so we can assert
//
DatabaseChangeLog changeLog = liquibase.getDatabaseChangeLog();
for (ChangeSet changeSet : changeLog.getChangeSets()) {
changeSet.addSqlVisitor(new TestSqlVisitor());
}
try {
liquibase.update(this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
database.commit();
}
use of liquibase.changelog.ChangeSet in project liquibase by liquibase.
the class HTMLWriter method writeChanges.
protected void writeChanges(String title, Writer fileWriter, List<Change> changes) throws IOException, DatabaseHistoryException, DatabaseException {
fileWriter.append("<p><TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" CELLSPACING=\"0\" SUMMARY=\"\">\n");
fileWriter.append("<TR BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">\n");
fileWriter.append("<TD COLSPAN='4'><FONT SIZE=\"+2\">\n");
fileWriter.append("<B>");
fileWriter.append(title);
fileWriter.append("</B></FONT></TD>\n");
fileWriter.append("</TR>\n");
ChangeSet lastChangeSet = null;
if ((changes == null) || changes.isEmpty()) {
fileWriter.append("<tr><td>None Found</td></tr>");
} else {
for (Change change : changes) {
if (!change.getChangeSet().equals(lastChangeSet)) {
lastChangeSet = change.getChangeSet();
fileWriter.append("<TR BGCOLOR=\"#EEEEFF\" CLASS=\"TableSubHeadingColor\">\n");
writeTD(fileWriter, "<a href='../changelogs/" + DBDocUtil.toFileName(change.getChangeSet().getFilePath().toLowerCase()) + ".html'>" + change.getChangeSet().getFilePath() + "</a>");
writeTD(fileWriter, change.getChangeSet().getId());
writeTD(fileWriter, "<a href='../authors/" + DBDocUtil.toFileName(change.getChangeSet().getAuthor().toLowerCase()) + ".html'>" + StringUtil.escapeHtml(change.getChangeSet().getAuthor().toLowerCase()) + "</a>");
ChangeSet.RunStatus runStatus = database.getRunStatus(change.getChangeSet());
if (runStatus.equals(ChangeSet.RunStatus.NOT_RAN)) {
String anchor = change.getChangeSet().toString(false).replaceAll("\\W", "_");
writeTD(fileWriter, "NOT YET RAN [<a href='../pending/sql.html#" + anchor + "'>SQL</a>]");
} else if (runStatus.equals(ChangeSet.RunStatus.INVALID_MD5SUM)) {
writeTD(fileWriter, "INVALID MD5SUM");
} else if (runStatus.equals(ChangeSet.RunStatus.ALREADY_RAN)) {
writeTD(fileWriter, "Executed " + DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(database.getRanDate(change.getChangeSet())));
} else if (runStatus.equals(ChangeSet.RunStatus.RUN_AGAIN)) {
writeTD(fileWriter, "Executed, WILL RUN AGAIN");
} else {
throw new RuntimeException("Unknown run status: " + runStatus);
}
fileWriter.append("</TR>");
if (StringUtil.trimToNull(change.getChangeSet().getComments()) != null) {
fileWriter.append("<TR><TD BGCOLOR='#EEEEFF' CLASS='TableSubHeadingColor' colspan='4'>").append(change.getChangeSet().getComments()).append("</TD></TR>");
}
}
fileWriter.append("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">\n");
fileWriter.append("<td colspan='4'> ").append(change.getConfirmationMessage()).append("</td></TR>");
}
}
fileWriter.append("</TABLE>");
fileWriter.append(" </P>");
}
Aggregations