Skip to content

Commit

Permalink
Merge pull request #870 from openmeterio/refactor/db-use-numeric
Browse files Browse the repository at this point in the history
refactor: use numeric type in the database
  • Loading branch information
turip authored May 10, 2024
2 parents f453098 + 9cc081f commit 8b8dc52
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/credit/postgres_connector/ent/schema/credit.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ func (CreditEntry) Fields() []ent.Field {
field.Other("feature_id", pgulid.ULID{}).Optional().Nillable().Immutable().SchemaType(map[string]string{
dialect.Postgres: "char(26)",
}),
// TODO: use decimal instead of float?
field.Float("amount").Optional().Nillable().Immutable(),
field.Float("amount").Optional().Nillable().Immutable().SchemaType(map[string]string{
dialect.Postgres: "numeric",
}),
field.Uint8("priority").Default(1).Immutable(),
field.Time("effective_at").Default(time.Now).Immutable(),
// Expiration
Expand All @@ -48,7 +49,9 @@ func (CreditEntry) Fields() []ent.Field {
field.Time("expiration_at").Optional().Nillable().Immutable(),
// Rollover
field.Enum("rollover_type").GoType(credit.GrantRolloverType("")).Optional().Nillable().Immutable(),
field.Float("rollover_max_amount").Optional().Nillable().Immutable(),
field.Float("rollover_max_amount").Optional().Nillable().Immutable().SchemaType(map[string]string{
dialect.Postgres: "numeric",
}),
field.JSON("metadata", map[string]string{}).Optional(),
// Rollover or void grants will have a parent_id
field.Other("parent_id", pgulid.ULID{}).Optional().Nillable().Immutable().SchemaType(map[string]string{
Expand Down

0 comments on commit 8b8dc52

Please sign in to comment.