Atlas now supports Snowflake sequences as first-class schema objects. Define them in HCL, and Atlas plans the right CREATE, ALTER, and DROP SEQUENCE statements. Tables, views, and tasks can declare sequence dependencies via depends_on.
Sequences in Snowflake generate unique, monotonically increasing (or decreasing) integer values, commonly used for surrogate keys and ordered ID columns. Atlas now manages sequences as first-class resources alongside your tables, views, and tasks.
Defining a Sequence
Use the sequence block to declare a sequence in your HCL schema. The schema attribute is required; start, increment, order, and comment are optional:
schema "sales" {}sequence "customer_id_seq" {schema = schema.salesstart = 1increment = 1comment = "Surrogate key for customer records"}
Using a Sequence as a Column Default
A typical pattern is to assign the next sequence value as a column default so new rows get unique IDs automatically. Declare depends_on on the table so Atlas creates the sequence before the table during migration:
table "customers" {schema = schema.salescolumn "id" {type = NUMBERdefault = sql("customer_id_seq.NEXTVAL")}column "email" {type = VARCHAR(255)}depends_on = [sequence.customer_id_seq]}
Generated SQL
Atlas generates CREATE SEQUENCE, ALTER SEQUENCE, and DROP SEQUENCE statements based on the diff between your desired and current state:
-- Create sequence "customer_id_seq"CREATE SEQUENCE "sales"."customer_id_seq"START = 1INCREMENT = 1NOORDERCOMMENT = 'Surrogate key for customer records';
Changing increment or order is handled with ALTER SEQUENCE SET:
-- Increase batch size for bulk loadsALTER SEQUENCE "sales"."customer_id_seq" SET INCREMENT = 100;
-- Changing start requires a recreate (Snowflake limitation)DROP SEQUENCE "sales"."customer_id_seq";CREATE SEQUENCE "sales"."customer_id_seq" START = 1000001 INCREMENT = 1 NOORDER;