swapSchema
Swaps two Snowflake schemas, exchanging all their contents and metadata. Useful for blue-green deployments or atomically switching between schema versions.
Note: Automatic rollback swaps the schemas back.
Known limitation: This change type does not support database inspection features (snapshot, diff, diff-changelog, and generate-changelog commands).
Available attributes
Attribute | Type | Description | Required |
|---|---|---|---|
| String | Name of the database containing the source schema | No |
| String | Name of the first schema to swap | Yes |
| String | Name of the database containing the target schema (cross-database) | No |
| String | Name of the second schema to swap | Yes |
| Boolean | Don't error if the source schema doesn't exist | No |
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
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-latest.xsd
http://www.liquibase.org/xml/ns/pro-snowflake
http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
<!-- Simple swap -->
<changeSet id="swap-schemas" author="examples">
<pro-snowflake:swapSchema
schemaName="SCHEMA_BLUE"
targetSchemaName="SCHEMA_GREEN"/>
</changeSet>
<!-- Swap with IF EXISTS -->
<changeSet id="swap-schemas-if-exists" author="examples">
<pro-snowflake:swapSchema
schemaName="STAGING"
targetSchemaName="PRODUCTION"
ifExists="true"/>
</changeSet>
<!-- Cross-database swap -->
<changeSet id="swap-schemas-cross-db" author="examples">
<pro-snowflake:swapSchema
catalogName="DEV_DB"
schemaName="ANALYTICS"
targetCatalogName="PROD_DB"
targetSchemaName="ANALYTICS"/>
</changeSet>
</databaseChangeLog>