renameSchema

Renames an existing schema in Snowflake, with support for cross-database moves.

Note: Automatic rollback renames the schema back to original name.

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

oldCatalogName

String

Name of the database containing the schema to rename

No

oldSchemaName

String

Current name of the schema

Yes

newCatalogName

String

Target database name (for cross-database rename)

No

newSchemaName

String

New name for the schema

Yes

ifExists

Boolean

Don't error if the 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 rename -->
  <changeSet id="rename-schema" author="examples">
    <pro-snowflake:renameSchema
                oldSchemaName="OLD_SCHEMA"
                newSchemaName="NEW_SCHEMA"/>
  </changeSet>
  <!-- Rename with IF EXISTS -->
  <changeSet id="rename-schema-if-exists" author="examples">
    <pro-snowflake:renameSchema
                oldSchemaName="TEMP_SCHEMA"
                newSchemaName="ARCHIVE_SCHEMA"
                ifExists="true"/>
  </changeSet>
  <!-- Cross-database rename -->
  <changeSet id="rename-schema-cross-db" author="examples">
    <pro-snowflake:renameSchema
                oldCatalogName="DEV_DB"
                oldSchemaName="ANALYTICS"
                newCatalogName="PROD_DB"
                newSchemaName="ANALYTICS"/>
  </changeSet>
</databaseChangeLog>