mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-25 12:00:29 +00:00
generate database schemas
This commit is contained in:
parent
4c76f6b367
commit
63cfeffc4d
70 changed files with 26933 additions and 1398 deletions
|
@ -1,4 +1,4 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
|
@ -22,6 +22,34 @@ type AuthTokensCreate struct {
|
|||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (atc *AuthTokensCreate) SetCreatedAt(t time.Time) *AuthTokensCreate {
|
||||
atc.mutation.SetCreatedAt(t)
|
||||
return atc
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableCreatedAt(t *time.Time) *AuthTokensCreate {
|
||||
if t != nil {
|
||||
atc.SetCreatedAt(*t)
|
||||
}
|
||||
return atc
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (atc *AuthTokensCreate) SetUpdatedAt(t time.Time) *AuthTokensCreate {
|
||||
atc.mutation.SetUpdatedAt(t)
|
||||
return atc
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableUpdatedAt(t *time.Time) *AuthTokensCreate {
|
||||
if t != nil {
|
||||
atc.SetUpdatedAt(*t)
|
||||
}
|
||||
return atc
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (atc *AuthTokensCreate) SetToken(b []byte) *AuthTokensCreate {
|
||||
atc.mutation.SetToken(b)
|
||||
|
@ -42,16 +70,16 @@ func (atc *AuthTokensCreate) SetNillableExpiresAt(t *time.Time) *AuthTokensCreat
|
|||
return atc
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (atc *AuthTokensCreate) SetCreatedAt(t time.Time) *AuthTokensCreate {
|
||||
atc.mutation.SetCreatedAt(t)
|
||||
// SetID sets the "id" field.
|
||||
func (atc *AuthTokensCreate) SetID(u uuid.UUID) *AuthTokensCreate {
|
||||
atc.mutation.SetID(u)
|
||||
return atc
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableCreatedAt(t *time.Time) *AuthTokensCreate {
|
||||
if t != nil {
|
||||
atc.SetCreatedAt(*t)
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableID(u *uuid.UUID) *AuthTokensCreate {
|
||||
if u != nil {
|
||||
atc.SetID(*u)
|
||||
}
|
||||
return atc
|
||||
}
|
||||
|
@ -115,9 +143,15 @@ func (atc *AuthTokensCreate) Save(ctx context.Context) (*AuthTokens, error) {
|
|||
}
|
||||
mut = atc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, atc.mutation); err != nil {
|
||||
v, err := mut.Mutate(ctx, atc.mutation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nv, ok := v.(*AuthTokens)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected node type %T returned from AuthTokensMutation", v)
|
||||
}
|
||||
node = nv
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
@ -146,27 +180,38 @@ func (atc *AuthTokensCreate) ExecX(ctx context.Context) {
|
|||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (atc *AuthTokensCreate) defaults() {
|
||||
if _, ok := atc.mutation.CreatedAt(); !ok {
|
||||
v := authtokens.DefaultCreatedAt()
|
||||
atc.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := atc.mutation.UpdatedAt(); !ok {
|
||||
v := authtokens.DefaultUpdatedAt()
|
||||
atc.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := atc.mutation.ExpiresAt(); !ok {
|
||||
v := authtokens.DefaultExpiresAt()
|
||||
atc.mutation.SetExpiresAt(v)
|
||||
}
|
||||
if _, ok := atc.mutation.CreatedAt(); !ok {
|
||||
v := authtokens.DefaultCreatedAt()
|
||||
atc.mutation.SetCreatedAt(v)
|
||||
if _, ok := atc.mutation.ID(); !ok {
|
||||
v := authtokens.DefaultID()
|
||||
atc.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (atc *AuthTokensCreate) check() error {
|
||||
if _, ok := atc.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AuthTokens.created_at"`)}
|
||||
}
|
||||
if _, ok := atc.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "AuthTokens.updated_at"`)}
|
||||
}
|
||||
if _, ok := atc.mutation.Token(); !ok {
|
||||
return &ValidationError{Name: "token", err: errors.New(`ent: missing required field "AuthTokens.token"`)}
|
||||
}
|
||||
if _, ok := atc.mutation.ExpiresAt(); !ok {
|
||||
return &ValidationError{Name: "expires_at", err: errors.New(`ent: missing required field "AuthTokens.expires_at"`)}
|
||||
}
|
||||
if _, ok := atc.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AuthTokens.created_at"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -174,12 +219,17 @@ func (atc *AuthTokensCreate) sqlSave(ctx context.Context) (*AuthTokens, error) {
|
|||
_node, _spec := atc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, atc.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
|
@ -189,11 +239,31 @@ func (atc *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) {
|
|||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: authtokens.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUUID,
|
||||
Column: authtokens.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if id, ok := atc.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := atc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldCreatedAt,
|
||||
})
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := atc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldUpdatedAt,
|
||||
})
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := atc.mutation.Token(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
|
@ -210,14 +280,6 @@ func (atc *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) {
|
|||
})
|
||||
_node.ExpiresAt = value
|
||||
}
|
||||
if value, ok := atc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldCreatedAt,
|
||||
})
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if nodes := atc.mutation.UserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@ -274,7 +336,7 @@ func (atcb *AuthTokensCreateBulk) Save(ctx context.Context) ([]*AuthTokens, erro
|
|||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, atcb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -283,10 +345,6 @@ func (atcb *AuthTokensCreateBulk) Save(ctx context.Context) ([]*AuthTokens, erro
|
|||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
if specs[i].ID.Value != nil {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue