createSchema

Creates a new schema in Snowflake. Schemas are logical groupings of database objects (tables, views, stages, etc.) and provide namespace isolation.

Note: Automatic rollback drops the schema.

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

catalogName

String

Name of the catalog (database) where the schema will be created

No

schemaName

String

Name of the schema to create

Yes

replaceIfExists

Boolean

Replace the schema if it exists using OR REPLACE*

No

alterIfExists

Boolean

Alter the schema if it exists using OR ALTER*

No

ifNotExists

Boolean

Only create if the schema doesn't exist using IF NOT EXISTS*

No

isTransient

Boolean

Create a transient schema (no Fail-safe period)

No

withManagedAccess

Boolean

Create managed access schema (only owner can grant privileges)

No

dataRetentionTimeInDays

Integer

Number of days to retain data for Time Travel

No

maxDataExtensionTimeInDays

Integer

Maximum number of days to extend data retention period

No

defaultDdlCollation

String

Default collation for tables/views created in this schema

No

classificationProfile

String

Fully-qualified name of classification profile

No

objectVisibility

String

Controls visibility of objects in INFORMATION_SCHEMA views

No

logLevel

String

Log level: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF

No

traceLevel

String

Trace event level: ALWAYS, ON_EVENT, OFF

No

comment

String

Comment describing the schema

No

tags

Map

Key-value pairs of tags to apply (tags must exist)**

No

contacts

Map

Contact purposes and names (valid: Steward, Support, Approver)**

No

* replaceIfExists, alterIfExists, and ifNotExists are mutually exclusive.

** tags and contacts are not supported with alterIfExists (CREATE OR ALTER).

<?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">
  <!-- Basic schema creation -->
  <changeSet id="create-basic-schema" author="examples">
    <pro-snowflake:createSchema schemaName="ANALYTICS"/>
  </changeSet>
  <!-- Schema with IF NOT EXISTS -->
  <changeSet id="create-schema-if-not-exists" author="examples">
    <pro-snowflake:createSchema
                schemaName="STAGING"
                ifNotExists="true"
                comment="Staging area for ETL"/>
  </changeSet>
  <!-- Full-featured schema with tags and contacts -->
  <changeSet id="create-full-schema" author="examples">
    <pro-snowflake:createSchema
                schemaName="PRODUCTION_DATA"
                isTransient="true"
                withManagedAccess="true"
                dataRetentionTimeInDays="1"
                maxDataExtensionTimeInDays="14"
                defaultDdlCollation="utf8"
                logLevel="INFO"
                traceLevel="ALWAYS"
                comment="Production data schema">
      <pro-snowflake:tags>
        <pro-snowflake:entry key="environment" value="production"/>
        <pro-snowflake:entry key="compliance" value="pci"/>
      </pro-snowflake:tags>
      <pro-snowflake:contacts>
        <pro-snowflake:entry key="Steward" value="data_owner"/>
        <pro-snowflake:entry key="Support" value="support_team"/>
      </pro-snowflake:contacts>
    </pro-snowflake:createSchema>
  </changeSet>
</databaseChangeLog>