entc: global id feature (#4293)

Feature to add annotations to ent schema to ensure sql tables have sequential auto-increment id columns. Meant to be a better alternative for entgql / gqlgen globally unique id feature.
This commit is contained in:
Jannik Clausen
2025-01-13 20:49:28 +01:00
committed by GitHub
parent adfd86c303
commit 6cfa2288bb
15 changed files with 351 additions and 19 deletions

View File

@@ -375,6 +375,21 @@ func OnDelete(opt ReferenceOption) *Annotation {
}
}
// IncrementStart specifies the starting value for auto-increment columns.
//
// For example, in order to define the starting value for auto-increment to be 100:
//
// func (T) Annotations() []schema.Annotation {
// return []schema.Annotation{
// entsql.IncrementStart(100),
// }
// }
func IncrementStart(i int64) *Annotation {
return &Annotation{
IncrementStart: &i,
}
}
// Merge implements the schema.Merger interface.
func (a Annotation) Merge(other schema.Annotation) schema.Annotation {
var ant Annotation