Q: How to create the liquibase dbchangelog programatically using java code? I recently used the liquibase change set to generateChangelog , diff and updateSQL to create the change log, to find the difference and to generate the ddl scripts respectively.
And my change log looked something like this and it was an xml file
<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
 xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">

<changeSet author="John (generated)" id="1439225004329-1">
 <createTable tableName="Author ">
    <column autoIncrement="true" name="id" type="BIGINT">
        <constraints primaryKey="true"/>
    </column> 
    <column name="name" type="VARCHAR(255)"/>
  </createTable>
</changeSet>

</databaseChangeLog>

I created this xml manually. And I was trying to create the same change log though java code.
I am having an hard time figuring out how to do this in java. Can someone put some light on this?
I have added liquibase 3.5.5 as maven dependency to my project.

A: what about this?
final Path changeLogPath = Paths.get("/tmp/mychangelog.xml");

final DatabaseChangeLog changeLog = new DatabaseChangeLog(changeLogPath.toString());
changeLog.setPhysicalFilePath("mychangelog.xml");

final CreateTableChange createTableChange = new CreateTableChange();
createTableChange.setTableName("firsttable");
createTableChange.addColumn(new ColumnConfig().setName("col1").setType("VARCHAR(20)"));

final ChangeSet changeSet = new ChangeSet("id1", "author", Boolean.FALSE, Boolean.FALSE, null, null, null, changeLog);
changeSet.addChange(createTableChange);

try (OutputStream os = new FileOutputStream(changeLogPath.toString())){
    serializer.write(changeLog.getChangeSets(), os);
}

