47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package schema
|
|
|
|
import (
|
|
"juwan-backend/pkg/types"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/dialect/entsql"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
// WalletTransactions holds the schema definition for the WalletTransactions entity.
|
|
type WalletTransactions struct {
|
|
ent.Schema
|
|
}
|
|
|
|
// Fields of the WalletTransactions.
|
|
func (WalletTransactions) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.String("id").Immutable().Unique(),
|
|
field.Int64("user_id").Immutable().Unique(),
|
|
field.String("type"),
|
|
field.Other("amount", decimal.Decimal{}).
|
|
SchemaType(map[string]string{
|
|
dialect.Postgres: "decimal(12,2",
|
|
}).Unique().Immutable(),
|
|
field.Other("balance_after", decimal.Decimal{}).
|
|
SchemaType(map[string]string{
|
|
dialect.Postgres: "decimal(12,2)",
|
|
}).Unique().Immutable(),
|
|
field.Other("description", types.TextArray{}).SchemaType(map[string]string{
|
|
dialect.Postgres: "text[]",
|
|
}).Optional(),
|
|
field.Int64("order_id").Immutable().Unique(),
|
|
field.Time("created_at"),
|
|
field.String("search_text").Optional().Immutable().Annotations(entsql.Annotation{
|
|
Skip: true,
|
|
}),
|
|
}
|
|
}
|
|
|
|
// Edges of the WalletTransactions.
|
|
func (WalletTransactions) Edges() []ent.Edge {
|
|
return nil
|
|
}
|