Alter Standard Table - Data Retention

Modifies data retention settings for Time Travel. Time Travel enables querying and restoring historical data within the retention period.

Known limitations:

  • This change type does not support automatic rollback.

  • Snowflake snapshots created with Liquibase Secure 5.1 are incompatible with earlier versions due to enhanced object type detection for TABLES and VIEWS. Regenerate all snapshots with 5.1 after upgrading to avoid false differences in diff and diff-changelog operations.

Available attributes

Attribute

Type

Description

Required

catalogName

String

Name of the catalog (database) containing the table

No

schemaName

String

Name of the schema containing the table

No

tableName

String

Name of the table to alter

Yes

ifExists

Boolean

Only execute if the table exists

No

alterDataRetention nested attributes

Attribute

Type

Description

Required

newDataRetentionTimeInDays

Integer

New Time Travel retention period (0-90 days)

No*

unsetDataRetentionTimeInDays

Boolean

If true, unsets the data retention time

No*

newMaxDataExtensionTimeInDays

Integer

New maximum extension period

No*

unsetMaxDataExtensionTimeInDays

Boolean

If true, unsets the max extension time

No*

*Specify at least one attribute. newDataRetentionTimeInDays and unsetDataRetentionTimeInDays are mutually exclusive. newMaxDataExtensionTimeInDays and unsetMaxDataExtensionTimeInDays are mutually exclusive.

<?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">
  <!-- Set data retention with extension time -->
  <changeSet id="alter-data-retention" author="examples">
    <pro-snowflake:alterStandardTable tableName="AUDIT_LOG">
      <pro-snowflake:alterDataRetention
                newDataRetentionTimeInDays="90"
                newMaxDataExtensionTimeInDays="14"/>
    </pro-snowflake:alterStandardTable>
  </changeSet>
  <!-- Set retention only -->
  <changeSet id="set-retention-only" author="examples">
    <pro-snowflake:alterStandardTable tableName="CUSTOMER_DATA">
      <pro-snowflake:alterDataRetention newDataRetentionTimeInDays="30"/>
    </pro-snowflake:alterStandardTable>
  </changeSet>
  <!-- Unset data retention -->
  <changeSet id="unset-data-retention" author="examples">
    <pro-snowflake:alterStandardTable tableName="TEMPORARY_DATA">
      <pro-snowflake:alterDataRetention
                unsetDataRetentionTimeInDays="true"
                unsetMaxDataExtensionTimeInDays="true"/>
    </pro-snowflake:alterStandardTable>
  </changeSet>
</databaseChangeLog>