Liquibase XML generator

前端 未结 1 1764
广开言路
广开言路 2021-01-12 13:53

Is there opensource/free liquibase (http://www.liquibase.org) xml generator?

Alternative to \"Power Architect and Liquibase combo\". Where can I create database mod

相关标签:
1条回答
  • 2021-01-12 14:51

    There isn't any available generator since I know.

    Actually you can do it by your own by using liquibase core classes.

    An example of use:

    // .. imports
    
    // create a changelog
    liquibase.changelog.DatabaseChangeLog databaseChangeLog = new liquibase.changelog.DatabaseChangeLog();
    
    // create a changeset
    liquibase.changelog.ChangeSet changeSet = new liquibase.changelog.ChangeSet("1", "prates", false, false, "", null, null, true, null, databaseChangeLog);
    
    // create a drop table change
    liquibase.change.core.DropTableChange dropTableChange = new liquibase.change.core.DropTableChange();
    
    dropTableChange.setTableName("person");
    
    changeSet.addChange(dropTableChange);
    
    // add created changeset to changelog
    databaseChangeLog.addChangeSet(changeSet);
    
    // create a new serializer
    XMLChangeLogSerializer xmlChangeLogSerializer = new XMLChangeLogSerializer();
    
    String output = null;
    
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    
    xmlChangeLogSerializer.write(databaseChangeLog.getChangeSets(), baos);
    
    output = baos.toString();
    
    // print output
    System.out.println(output);
    
    0 讨论(0)
提交回复
热议问题