addStandardTableColumn
Adds a new column to an existing Snowflake standard table.
Note: This change type does not support automatic rollback.
Available attributes
Attribute | Type | Description | Required |
|---|---|---|---|
| String | Name of the catalog (database) containing the table | No |
| String | Name of the schema containing the table | No |
| String | Name of the table to add the column to | Yes |
| String | Name of the new column | Yes |
| String | Data type of the new column | Yes |
| Boolean | Only execute if the table exists | No |
| Boolean | Only add column if it doesn't already exist | No |
| Boolean | If false, adds NOT NULL constraint | No |
| String | Column collation specification | No |
| String | Column comment | No |
Default value attributes
Only one default value attribute should be specified:
Attribute | Type | Description | Required |
|---|---|---|---|
| String | Default string value | No |
| String | Default numeric value | No |
| Boolean | Default boolean value | No |
| String | Default date value (yyyy-MM-dd format) | No |
| String | Computed default expression | No |
| String | Sequence name for NEXTVAL default | No |
| String | Sequence name for CURRVAL default | No |
Snowflake-specific attributes
Attribute | Type | Description | Required |
|---|---|---|---|
| String | Name of masking policy to apply | No |
| String | Additional columns for conditional masking | No |
| String | Name of projection policy to apply | No |
| Object | Map of tag names to values | No |
Basic column
<?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">
<!-- Add a basic column -->
<changeSet id="add-basic-column" author="examples">
<pro-snowflake:addStandardTableColumn
tableName="CUSTOMERS"
columnName="PHONE_NUMBER"
columnType="VARCHAR(20)"/>
</changeSet>
<!-- Add a NOT NULL column with default -->
<changeSet id="add-not-null-column" author="examples">
<pro-snowflake:addStandardTableColumn
tableName="CUSTOMERS"
columnName="STATUS"
columnType="VARCHAR(10)"
nullable="false"
defaultValue="ACTIVE"/>
</changeSet>
<!-- Add column only if it doesn't exist -->
<changeSet id="add-column-if-not-exists" author="examples">
<pro-snowflake:addStandardTableColumn
tableName="CUSTOMERS"
columnName="CREATED_AT"
columnType="TIMESTAMP_NTZ"
ifNotExists="true"
defaultValueComputed="CURRENT_TIMESTAMP()"/>
</changeSet>
</databaseChangeLog>Column with policies and tags
<?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">
<!-- Add column with masking policy -->
<changeSet id="add-column-with-masking" author="examples">
<pro-snowflake:addStandardTableColumn
tableName="CUSTOMERS"
columnName="SSN"
columnType="VARCHAR(11)"
maskingPolicy="SSN_MASK"
comment="Social Security Number (masked)"/>
</changeSet>
<!-- Add column with tags -->
<changeSet id="add-column-with-tags" author="examples">
<pro-snowflake:addStandardTableColumn
tableName="CUSTOMERS"
columnName="EMAIL"
columnType="VARCHAR(255)">
<pro-snowflake:tags>
<pro-snowflake:entry key="PII" value="true"/>
<pro-snowflake:entry key="SENSITIVITY" value="HIGH"/>
</pro-snowflake:tags>
</pro-snowflake:addStandardTableColumn>
</changeSet>
<!-- Add column with projection policy -->
<changeSet id="add-column-with-projection" author="examples">
<pro-snowflake:addStandardTableColumn
tableName="SENSITIVE_DATA"
columnName="SECRET_KEY"
columnType="VARCHAR(256)"
projectionPolicy="NO_PROJECTION"/>
</changeSet>
</databaseChangeLog>Column with collation
<?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">
<!-- Add column with case-insensitive collation -->
<changeSet id="add-column-with-collation" author="examples">
<pro-snowflake:addStandardTableColumn
tableName="CUSTOMERS"
columnName="COUNTRY"
columnType="VARCHAR(100)"
collation="en-ci"/>
</changeSet>
</databaseChangeLog>