renameRole

Renames an existing role in Snowflake.

Attributes

Attribute

Type

Description

Required

oldRoleName

String

Current name of the role

Yes

newRoleName

String

New name for the role

Yes

ifExists

Boolean

If true, only renames if the role exists using `IF EXISTS`

No

<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">
  <changeSet id="rename-role" author="examples">
    <!-- Create role -->
    <sql>CREATE ROLE IF NOT EXISTS DATA_ANALYST_ROLE</sql>
    <!-- Rename role - this is what we're testing -->
    <pro-snowflake:renameRole
            oldRoleName="DATA_ANALYST_ROLE"
            newRoleName="ANALYTICS_ROLE"/>
    <rollback>
      <sql>DROP ROLE IF EXISTS ANALYTICS_ROLE</sql>
    </rollback>
  </changeSet>
  <changeSet id="rename-role-if-exists" author="examples">
    <!-- Rename role with IF EXISTS clause -->
    <pro-snowflake:renameRole
            oldRoleName="ANALYTICS_ROLE"
            newRoleName="SENIOR_ANALYST_ROLE"
            ifExists="true"/>
  </changeSet>
</databaseChangeLog>