How To: Clone a Liquibase Enterprise project


I have an existing Liquibase Enterprise / DaticalDB project that I want to duplicate and modify instead of creating a new one from scratch.


Disclaimer: This is an advanced topic.

  • Talk to your Customer Success team if you need help.
  • This only works when cloning projects on the same database platform.

Step-by-step guide

For the purpose of this article, we will use the following naming conventions:

  • original project name: EPOD_CMS
  • new project name: Portal

SCM

The first thing to do is to create repositories for your new project and its associated SQL scripts.

  1. For the SQL script repository, refer to your Implementation Guide on setting up with your particular SCM (or co-locate in the existing developer application repository).
    1. Copy the sql script directory structure from the original repository.
    2. You might need to remove or at least validate the values in any existing metadata.properties files. 
    3. Be sure to note the last Commit ID (this will be used later in the deployPackager.properties file).
  2. For the Datical DB project, create an empty new repository. For this article, we will call the repository: portal_ddb.

Copy your old project

  1. Go to your workstation/client and checkout/pull the newly created new repo: portal_ddb.
  2. Copy the contents of the Datical project you want to clone into the new directory
    1. Remove any SCM administration folders like ".git/", ".svn/", etc.)
  3. Now let's modify some files.

Files to modify

.project

Replace the name of the project at the top of file from:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
  <name>EPOD_CMS</name>

to 

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
  <name>Portal</name>

and save.

datical.project

Here you will have a little more editing to do depending on your use case:

  • Change the name on the first line to:
    name="Portal"
  • Remove the projectsId content from: 

    projectsId="ec91d5b7-bf95-4249-af7f-f06dde742cb9"

    to 

    projectsId=""
  • Edit your database connections by editing the matching DbDefs.
    • You will need to use the UI to enter a different password. If you do not have access to the UI, you can Base64 encode the password as the value in the datical.project.
    • You will need to change the managed database or schema(s) information in the new project.
    • Remove any dbDefsId content from: 

      dbDefsId="3cc01c15-727a-34c1-ba97-5aafd139b839"

      to 

      dbDefsId=""
  • Edit your plans.
    • Remove any plansId content from: 

      plansId="b5e83263-beff-3eb6-8f41-0d1881ee330e"

      to 

      plansId=""

Your file should look like

<?xml version="1.0" encoding="ASCII"?>
<dbproject:Project xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dbproject="http://datical.com/db/project/1.0" name="Portal" storedLogicExternal="true" deployThreshold="stopOnError" requireOptions="true" projectsId="" runtimeCredentials="false" multiSchema="true" dbSchemaDefinition="project" schemaSelectionStep="REF1" trackingSchema="DATICALDBTRACKING" enableRowCount="true">
  <dbDefs xsi:type="dbproject:OracleDbDef" name="REF1" driver="oracle.jdbc.OracleDriver" hostname="localhost" port="1521" username="DATICAL_USER" password="REFUSUNBTF9VU0VS" contexts="REF,REF1" storageOptionCollectedAtSnapshot="true" labels="current" dbDefsId="" serviceName="CMS_REF1" enableCompression="false" rowsPerBatch="10000"/>
  <dbDefs xsi:type="dbproject:OracleDbDef" name="REF2" driver="oracle.jdbc.OracleDriver" hostname="localhost" port="1521" username="DATICAL_USER" password="REFUSUNBTF9VU0VS" contexts="REF,REF2" storageOptionCollectedAtSnapshot="true" labels="next" dbDefsId="" serviceName="CMS_REF2" enableCompression="false" rowsPerBatch="10000"/>
  <dbDefs xsi:type="dbproject:OracleDbDef" name="DEVINT1" driver="oracle.jdbc.OracleDriver" hostname="localhost" port="1521" username="DATICAL_USER" password="REFUSUNBTF9VU0VS" contexts="DEV, DEVINT1" storageOptionCollectedAtSnapshot="true" labels="current" dbDefsId="" serviceName="CMS_INT1" enableCompression="false" rowsPerBatch="10000"/>
  <dbDefs xsi:type="dbproject:OracleDbDef" name="DEVINT2" driver="oracle.jdbc.OracleDriver" hostname="localhost" port="1521" username="DATICAL_USER" password="REFUSUNBTF9VU0VS" contexts="DEV, DEVINT2" storageOptionCollectedAtSnapshot="true" labels="next" dbDefsId="" serviceName="CMS_INT2" enableCompression="false" rowsPerBatch="10000"/>
  <dbDefs xsi:type="dbproject:OracleDbDef" name="QA" driver="oracle.jdbc.OracleDriver" hostname="localhost" port="1521" username="DATICAL_USER" password="REFUSUNBTF9VU0VS" contexts="QA" storageOptionCollectedAtSnapshot="true"  dbDefsId="" serviceName="CMS_QA" enableCompression="false" rowsPerBatch="10000"/>
  <dbDefs xsi:type="dbproject:OracleDbDef" name="PROD" driver="oracle.jdbc.OracleDriver" hostname="localhost" port="1521" username="DATICAL_USER" password="REFUSUNBTF9VU0VS" contexts="PROD" storageOptionCollectedAtSnapshot="true"  dbDefsId="" serviceName="CMS_PROD" enableCompression="false" rowsPerBatch="10000"/>
  <plans name="current" databaseDefs="//@dbDefs[name='REF1'] //@dbDefs[name='DEVINT1'] //@dbDefs[name='QA'] //@dbDefs[name='PROD']" plansId=""/>
  <plans name="next" databaseDefs="//@dbDefs[name='REF2'] //@dbDefs[name='DEVINT2'] //@dbDefs[name='QA'] //@dbDefs[name='PROD']" plansId=""/>
  <changelog href="Changelog/changelog.xml#//@databaseChangeLog"/>
  <dmcDB xsi:type="dbproject:PostgresqlDbDef" name="DMCDB" driver="org.postgresql.Driver" hostname="dmc-db.liquibase.net" port="5432" username="datical_user" password="ZGF3aWNhbF91c9Vy" dbDefType="dmcdb" database="cs_dmc"/>
  <releaseLabels name="current AND !abandoned" description="Deploy changesets from the current pipeline that have not been abandoned"/>
  <releaseLabels name="hotfix AND !abandoned" description="Deploy changesets from the hotfix pipeline that have not been abandoned"/>
  <schemas name="TRAINING"/>
  <schemas name="APP_SCHEMA"/>
</dbproject:Project>


Changelog/changelog.xml

Remove all the changesets and simply keep the first 2 lines and the last one. Your changelog.xml should match the following example:

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:appdba="http://www.datical.net/xml/ns/appdba" xmlns:datical="http://www.datical.net/xml/ns/datical" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:storedlogic="http://www.datical.net/xml/ns/storedlogic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" logicalFilePath="Changelog/changelog.xml" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
</databaseChangeLog>

deployPackager.properties

  1. Be sure to replace the scmLastImportID (you remembered to save it in step 1) for the main branch and all additional branches.
  2. Also don't forget to change the sqlScmPath as required for the path to the new Portal_SQL/sql_code repository


sqlScmSystem=git
ddbScmSystem=git
databaseBackupRestoreLocation=
sqlScmLastImportID=b167ebdc209c90c7d2b97fb009fe9014a0457616
ddbScmPath=./
sqlScmPath=../portal_sql
sqlScmSQLBaseDir=sql_code

Directories and files to delete

The following directories can be deleted

  • Logs
  • Reports
  • Snapshots
  • Profiles

You can also delete any log in the top level directory like daticaldb.log

Commit

You should now be able to commit your updated datical project to the new repository.

Final steps

GUI

Now open the Datical UI and import your project. If the system does not let you, it's certainly because one the files has an issue. Using an XML online validator can help to find some syntax issues. It could also be because you forget to update the ".project" file and the system detects a duplicate name for a project

  1. Check your connections
  2. Update your passwords as needed
  3. Register your project in your DMC DB
  4. Run a status

Copyright © Datical 2012-2020 - Proprietary and Confidential