I have a software wich uses multiple schemas. I made db.changelog-master.xml to maintain different releases and db.changelog-S16.xml to current sprint (it's currently sprint 16 going on). db.changelog-S16.xml is looking like this:
<?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">
<include file="my_schema_1.xml" relativeToChangelogFile="true" />
</databaseChangeLog>
Problem here is, that I want to make one changelog which could update all the schemas in one but I have failed to find a way to hardcode the schemaname in the changelog. Can it be obtained to the changelog via generateChangelog somehow (so the schemanames would be in my_schema_1.xml), or can I type it to the changelog? What I am looking for would be like this:
<?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">
<TAG WHERE I COULD INSERT SCHEMANAME>
<include file="my_schema_1.xml" relativeToChangelogFile="true" />
<TAG WHERE I COULD INSERT SCHEMANAME>
<include file="my_schema_2.xml" relativeToChangelogFile="true" />
etc...
</databaseChangeLog>
Because now it is only possibly to change schema in the update clause when running the liquibase from the commandline. This would be handy too when I am making customer databases to their servers. I could just make customer_master.xml and hardcode their schemanames in it and then run it to their server from the scratch. So far only place I have found to insert schema name is when you make the commandline call. That would mean that I would have to update each schema differently or make some powershell script to do them for me...
In Liquibase there is no "create schema" tag, because it is designed to manage objects within the application's schema. However, we can use a custom SQL statement inside a 'sql' tag to make a creation of a schema a part of our migration.
There's a lot more Liquibase can do! For starters, you can create database changes with Liquibase using plain SQL, XML, JSON, or YAML. You can also embed Liquibase in your application or in automation.
Hibernate and Liquibase are primarily classified as "Object Relational Mapper (ORM)" and "Database" tools respectively.
Snowflake enables data storage, processing, and analytic solutions and runs on the cloud infrastructure.
Most change tags have a "schemaName" attribute that you can use to specify the schema. For example, <createTable tableName="person" schemaName="customer">
If your schemas are always named the same, you can hard code them directly into the change tags. If they change from deploy to deply, you probably want to use changelog parameters so you can use <createTable tableName="person" schemaName="${primarySchema}">
and then specify what primarySchema is equal to at runtime.
You will need to specify the schemaName on each changeSet, otherwise it will use the default schemaName which cannot be changed part way through the script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With