generate database schemas

This commit is contained in:
Hayden 2022-08-30 10:04:50 -08:00
parent 4c76f6b367
commit 63cfeffc4d
70 changed files with 26933 additions and 1398 deletions

View file

@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@ -17,13 +17,15 @@ import (
type AuthTokens struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
ID uuid.UUID `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// Token holds the value of the "token" field.
Token []byte `json:"token,omitempty"`
// ExpiresAt holds the value of the "expires_at" field.
ExpiresAt time.Time `json:"expires_at,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the AuthTokensQuery when eager-loading is set.
Edges AuthTokensEdges `json:"edges"`
@ -44,8 +46,7 @@ type AuthTokensEdges struct {
func (e AuthTokensEdges) UserOrErr() (*User, error) {
if e.loadedTypes[0] {
if e.User == nil {
// The edge user was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: user.Label}
}
return e.User, nil
@ -60,10 +61,10 @@ func (*AuthTokens) scanValues(columns []string) ([]interface{}, error) {
switch columns[i] {
case authtokens.FieldToken:
values[i] = new([]byte)
case authtokens.FieldID:
values[i] = new(sql.NullInt64)
case authtokens.FieldExpiresAt, authtokens.FieldCreatedAt:
case authtokens.FieldCreatedAt, authtokens.FieldUpdatedAt, authtokens.FieldExpiresAt:
values[i] = new(sql.NullTime)
case authtokens.FieldID:
values[i] = new(uuid.UUID)
case authtokens.ForeignKeys[0]: // user_auth_tokens
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
@ -82,11 +83,23 @@ func (at *AuthTokens) assignValues(columns []string, values []interface{}) error
for i := range columns {
switch columns[i] {
case authtokens.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
at.ID = *value
}
case authtokens.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
at.CreatedAt = value.Time
}
case authtokens.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
at.UpdatedAt = value.Time
}
at.ID = int(value.Int64)
case authtokens.FieldToken:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field token", values[i])
@ -99,12 +112,6 @@ func (at *AuthTokens) assignValues(columns []string, values []interface{}) error
} else if value.Valid {
at.ExpiresAt = value.Time
}
case authtokens.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
at.CreatedAt = value.Time
}
case authtokens.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field user_auth_tokens", values[i])
@ -132,11 +139,11 @@ func (at *AuthTokens) Update() *AuthTokensUpdateOne {
// Unwrap unwraps the AuthTokens entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (at *AuthTokens) Unwrap() *AuthTokens {
tx, ok := at.config.driver.(*txDriver)
_tx, ok := at.config.driver.(*txDriver)
if !ok {
panic("ent: AuthTokens is not a transactional entity")
}
at.config.driver = tx.drv
at.config.driver = _tx.drv
return at
}
@ -144,13 +151,18 @@ func (at *AuthTokens) Unwrap() *AuthTokens {
func (at *AuthTokens) String() string {
var builder strings.Builder
builder.WriteString("AuthTokens(")
builder.WriteString(fmt.Sprintf("id=%v", at.ID))
builder.WriteString(", token=")
builder.WriteString(fmt.Sprintf("%v", at.Token))
builder.WriteString(", expires_at=")
builder.WriteString(at.ExpiresAt.Format(time.ANSIC))
builder.WriteString(", created_at=")
builder.WriteString(fmt.Sprintf("id=%v, ", at.ID))
builder.WriteString("created_at=")
builder.WriteString(at.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(at.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("token=")
builder.WriteString(fmt.Sprintf("%v", at.Token))
builder.WriteString(", ")
builder.WriteString("expires_at=")
builder.WriteString(at.ExpiresAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}