Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: more sequence information (#17793)

rebelice977a226e7fa2
diff --git a/backend/plugin/schema/pg/get_database_definition.go b/backend/plugin/schema/pg/get_database_definition.go
index b18a937758..7ec089b663 100644
--- a/backend/plugin/schema/pg/get_database_definition.go
+++ b/backend/plugin/schema/pg/get_database_definition.go
@@ -2827,46 +2827,57 @@ func writeSequenceSDL(out io.Writer, schemaName string, sequence *storepb.Sequen
return err
}
- // Add data type if not default (bigint)
- if sequence.DataType != "" && sequence.DataType != "bigint" {
+ // Add data type (always output for consistency with non-SDL format)
+ if sequence.DataType != "" {
if _, err := fmt.Fprintf(out, " AS %s", sequence.DataType); err != nil {
return err
}
}
- // Add START WITH if not default (1)
- if sequence.Start != "" && sequence.Start != "1" {
+ // Add START WITH (always output for consistency with non-SDL format)
+ if sequence.Start != "" {
if _, err := fmt.Fprintf(out, " START WITH %s", sequence.Start); err != nil {
return err
}
}
- // Add INCREMENT BY if not default (1)
- if sequence.Increment != "" && sequence.Increment != "1" {
+ // Add INCREMENT BY (always output for consistency with non-SDL format)
+ if sequence.Increment != "" {
if _, err := fmt.Fprintf(out, " INCREMENT BY %s", sequence.Increment); err != nil {
return err
}
}
- // Add MINVALUE if specified and not default
- if sequence.MinValue != "" && sequence.MinValue != "1" && sequence.MinValue != "-9223372036854775808" {
+ // Add MINVALUE (always output for consistency with non-SDL format)
+ if sequence.MinValue != "" {
if _, err := fmt.Fprintf(out, " MINVALUE %s", sequence.MinValue); err != nil {
return err
}
}
- // Add MAXVALUE if specified and not default
- if sequence.MaxValue != "" && sequence.MaxValue != "9223372036854775807" {
+ // Add MAXVALUE (always output for consistency with non-SDL format)
+ if sequence.MaxValue != "" {
if _, err := fmt.Fprintf(out, " MAXVALUE %s", sequence.MaxValue); err != nil {
return err
}
}
- // Add CYCLE if true (NO CYCLE is the default)
+ // Add CYCLE/NO CYCLE (always output for consistency with non-SDL format)
if sequence.Cycle {
if _, err := io.WriteString(out, " CYCLE"); err != nil {
return err
}
+ } else {
+ if _, err := io.WriteString(out, " NO CYCLE"); err != nil {
+ return err
+ }
+ }
+
+ // Add CACHE (new field to match non-SDL format)
+ if sequence.CacheSize != "" {
+ if _, err := fmt.Fprintf(out, " CACHE %s", sequence.CacheSize); err != nil {
+ return err
+ }
}
return nil
diff --git a/backend/plugin/schema/pg/get_database_definition_sdl_test.go b/backend/plugin/schema/pg/get_database_definition_sdl_test.go
index 3766266ea2..ba34168300 100644
--- a/backend/plugin/schema/pg/get_database_definition_sdl_test.go
+++ b/backend/plugin/schema/pg/get_database_definition_sdl_test.go
@@ -637,7 +637,7 @@ $$;
},
},
},
- expected: `CREATE SEQUENCE "public"."independent_seq";
+ expected: `CREATE SEQUENCE "public"."independent_seq" AS bigint START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 NO CYCLE;
CREATE SEQUENCE "public"."order_seq" AS integer START WITH 1000 INCREMENT BY 10 MINVALUE 1000 MAXVALUE 999999 CYCLE;