liquibase
--driver=org.mariadb.jdbc.Driver
--classpath=./mariadb-java-client-1.4.6.jar
--url="jdbc:mariadb://<IP OR HOSTNAME>:<PORT>/<SCHEMA NAME>"
--changeLogFile=db.changelog-1.0.xml
--username=<MARIADB USERNAME>
--password=<MARIADB PASSWORD>
generateChangeLog
The purpose of this document is to guide you through the process of creating a new Liquibase project with MariaDB AWS RDS on a Windows machine. In this tutorial, you will generate an example project and follow the instructions to apply and learn concepts associated with creating new Liquibase Projects with MariaDB AWS RDS.
Note: Place the jdbc jar driver file in a known directory so you can locate it easily.
Example: C:\Users\Liquibase_Drivers\mariadb-java-client-2.4.4.jar
<?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.8.xsd">
</databaseChangeLog>
changeLogFile: C:\\Users\\Administrator\\LiquibaseMariaDB_RDS\\dbchangelog.xml
url: jdbc:mariadb:// myrds.cz1j1vh9uvuo.us-east-1.rds.amazonaws.com:3306/mydatabase
username: myrds
password: password
driver: org.mariadb.jdbc.Driver
classpath: ../../Liquibase_Drivers/ mariadb-java-client-2.4.4.jar
Because you are creating this project on Windows OS, you must specify the path with double slashes in the changeLogFile property. You must also use a relative path from your project directory to the driver jdbc jar file location in the classpath property. Also, the url property should follow this template:
In our case, since we are using AWS RDS database instance, the host name should be copied from AWS website under your RDS –> Databases –> <database name>
–> Connectivity & security –> Endpoint <copy the endpoint value>
. This value should look similar to the value mentioned in the liquibase.properties example above.
Note: If you already have a Liquibase Pro key and want to apply it to your project, add the following property to your liquibase.properties file.
liquibaseProLicenseKey: `<paste license key>`
<?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.8.xsd">
<changeSet id="1" author="bob">
<createTable tableName="department">
<column name="id" type="int">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="name" type="varchar(50)">
<constraints nullable="false"/>
</column>
<column name="active" type="boolean"
defaultValueBoolean="true"/>
</createTable>
</changeSet>
</databaseChangeLog>
Note: This create table change set is XML format. The corresponding SQL statement should look like the following:
CREATE TABLE "department"
("id" number(*,0),
"name" VARCHAR2(50 BYTE),
"active" NUMBER(1,0) DEFAULT 1
);
liquibase update
SELECT * FROM my_schema.department;
ID | NAME | ACTIVE |
---|---|---|
NULL | NULL | NULL |
Also, you should see two more tables:
ID | AUTHOR | FILENAME | DATEEXECUTED | ORDEREXECUTED | EXECTYPE | MDSUM | … |
---|---|---|---|---|---|---|---|
1 | bob | dbchangelog.xml | date&time |
1 | EXECUTED | checksumvalue |
… |