mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-04 08:40:28 +00:00
reset migration state
This commit is contained in:
parent
4e21cd03be
commit
7cf76294a4
13 changed files with 54 additions and 326 deletions
|
@ -61,8 +61,6 @@ type Item struct {
|
|||
SoldPrice float64 `json:"sold_price,omitempty"`
|
||||
// SoldNotes holds the value of the "sold_notes" field.
|
||||
SoldNotes string `json:"sold_notes,omitempty"`
|
||||
// TestMigrationField holds the value of the "test_migration_field" field.
|
||||
TestMigrationField string `json:"test_migration_field,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ItemQuery when eager-loading is set.
|
||||
Edges ItemEdges `json:"edges"`
|
||||
|
@ -151,7 +149,7 @@ func (*Item) scanValues(columns []string) ([]interface{}, error) {
|
|||
values[i] = new(sql.NullFloat64)
|
||||
case item.FieldQuantity:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case item.FieldName, item.FieldDescription, item.FieldImportRef, item.FieldNotes, item.FieldSerialNumber, item.FieldModelNumber, item.FieldManufacturer, item.FieldWarrantyDetails, item.FieldPurchaseFrom, item.FieldSoldTo, item.FieldSoldNotes, item.FieldTestMigrationField:
|
||||
case item.FieldName, item.FieldDescription, item.FieldImportRef, item.FieldNotes, item.FieldSerialNumber, item.FieldModelNumber, item.FieldManufacturer, item.FieldWarrantyDetails, item.FieldPurchaseFrom, item.FieldSoldTo, item.FieldSoldNotes:
|
||||
values[i] = new(sql.NullString)
|
||||
case item.FieldCreatedAt, item.FieldUpdatedAt, item.FieldWarrantyExpires, item.FieldPurchaseTime, item.FieldSoldTime:
|
||||
values[i] = new(sql.NullTime)
|
||||
|
@ -308,12 +306,6 @@ func (i *Item) assignValues(columns []string, values []interface{}) error {
|
|||
} else if value.Valid {
|
||||
i.SoldNotes = value.String
|
||||
}
|
||||
case item.FieldTestMigrationField:
|
||||
if value, ok := values[j].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field test_migration_field", values[j])
|
||||
} else if value.Valid {
|
||||
i.TestMigrationField = value.String
|
||||
}
|
||||
case item.ForeignKeys[0]:
|
||||
if value, ok := values[j].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_items", values[j])
|
||||
|
@ -443,9 +435,6 @@ func (i *Item) String() string {
|
|||
builder.WriteString(", ")
|
||||
builder.WriteString("sold_notes=")
|
||||
builder.WriteString(i.SoldNotes)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("test_migration_field=")
|
||||
builder.WriteString(i.TestMigrationField)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
|
|
@ -55,8 +55,6 @@ const (
|
|||
FieldSoldPrice = "sold_price"
|
||||
// FieldSoldNotes holds the string denoting the sold_notes field in the database.
|
||||
FieldSoldNotes = "sold_notes"
|
||||
// FieldTestMigrationField holds the string denoting the test_migration_field field in the database.
|
||||
FieldTestMigrationField = "test_migration_field"
|
||||
// EdgeGroup holds the string denoting the group edge name in mutations.
|
||||
EdgeGroup = "group"
|
||||
// EdgeLocation holds the string denoting the location edge name in mutations.
|
||||
|
@ -128,7 +126,6 @@ var Columns = []string{
|
|||
FieldSoldTo,
|
||||
FieldSoldPrice,
|
||||
FieldSoldNotes,
|
||||
FieldTestMigrationField,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "items"
|
||||
|
@ -194,8 +191,6 @@ var (
|
|||
DefaultSoldPrice float64
|
||||
// SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save.
|
||||
SoldNotesValidator func(string) error
|
||||
// DefaultTestMigrationField holds the default value on creation for the "test_migration_field" field.
|
||||
DefaultTestMigrationField string
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
|
|
@ -229,13 +229,6 @@ func SoldNotes(v string) predicate.Item {
|
|||
})
|
||||
}
|
||||
|
||||
// TestMigrationField applies equality check predicate on the "test_migration_field" field. It's identical to TestMigrationFieldEQ.
|
||||
func TestMigrationField(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
|
@ -2047,105 +2040,6 @@ func SoldNotesContainsFold(v string) predicate.Item {
|
|||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldEQ applies the EQ predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldEQ(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldNEQ applies the NEQ predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldNEQ(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldIn applies the In predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldIn(vs ...string) predicate.Item {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.In(s.C(FieldTestMigrationField), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldNotIn applies the NotIn predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldNotIn(vs ...string) predicate.Item {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.NotIn(s.C(FieldTestMigrationField), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldGT applies the GT predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldGT(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldGTE applies the GTE predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldGTE(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldLT applies the LT predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldLT(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldLTE applies the LTE predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldLTE(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldContains applies the Contains predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldContains(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldHasPrefix applies the HasPrefix predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldHasPrefix(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldHasSuffix applies the HasSuffix predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldHasSuffix(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldEqualFold applies the EqualFold predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldEqualFold(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// TestMigrationFieldContainsFold applies the ContainsFold predicate on the "test_migration_field" field.
|
||||
func TestMigrationFieldContainsFold(v string) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldTestMigrationField), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HasGroup applies the HasEdge predicate on the "group" edge.
|
||||
func HasGroup() predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
|
|
|
@ -312,20 +312,6 @@ func (ic *ItemCreate) SetNillableSoldNotes(s *string) *ItemCreate {
|
|||
return ic
|
||||
}
|
||||
|
||||
// SetTestMigrationField sets the "test_migration_field" field.
|
||||
func (ic *ItemCreate) SetTestMigrationField(s string) *ItemCreate {
|
||||
ic.mutation.SetTestMigrationField(s)
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetNillableTestMigrationField sets the "test_migration_field" field if the given value is not nil.
|
||||
func (ic *ItemCreate) SetNillableTestMigrationField(s *string) *ItemCreate {
|
||||
if s != nil {
|
||||
ic.SetTestMigrationField(*s)
|
||||
}
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (ic *ItemCreate) SetID(u uuid.UUID) *ItemCreate {
|
||||
ic.mutation.SetID(u)
|
||||
|
@ -520,10 +506,6 @@ func (ic *ItemCreate) defaults() {
|
|||
v := item.DefaultSoldPrice
|
||||
ic.mutation.SetSoldPrice(v)
|
||||
}
|
||||
if _, ok := ic.mutation.TestMigrationField(); !ok {
|
||||
v := item.DefaultTestMigrationField
|
||||
ic.mutation.SetTestMigrationField(v)
|
||||
}
|
||||
if _, ok := ic.mutation.ID(); !ok {
|
||||
v := item.DefaultID()
|
||||
ic.mutation.SetID(v)
|
||||
|
@ -601,9 +583,6 @@ func (ic *ItemCreate) check() error {
|
|||
return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := ic.mutation.TestMigrationField(); !ok {
|
||||
return &ValidationError{Name: "test_migration_field", err: errors.New(`ent: missing required field "Item.test_migration_field"`)}
|
||||
}
|
||||
if _, ok := ic.mutation.GroupID(); !ok {
|
||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Item.group"`)}
|
||||
}
|
||||
|
@ -811,14 +790,6 @@ func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) {
|
|||
})
|
||||
_node.SoldNotes = value
|
||||
}
|
||||
if value, ok := ic.mutation.TestMigrationField(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldTestMigrationField,
|
||||
})
|
||||
_node.TestMigrationField = value
|
||||
}
|
||||
if nodes := ic.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
|
|
@ -377,20 +377,6 @@ func (iu *ItemUpdate) ClearSoldNotes() *ItemUpdate {
|
|||
return iu
|
||||
}
|
||||
|
||||
// SetTestMigrationField sets the "test_migration_field" field.
|
||||
func (iu *ItemUpdate) SetTestMigrationField(s string) *ItemUpdate {
|
||||
iu.mutation.SetTestMigrationField(s)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillableTestMigrationField sets the "test_migration_field" field if the given value is not nil.
|
||||
func (iu *ItemUpdate) SetNillableTestMigrationField(s *string) *ItemUpdate {
|
||||
if s != nil {
|
||||
iu.SetTestMigrationField(*s)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (iu *ItemUpdate) SetGroupID(id uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.SetGroupID(id)
|
||||
|
@ -913,13 +899,6 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
Column: item.FieldSoldNotes,
|
||||
})
|
||||
}
|
||||
if value, ok := iu.mutation.TestMigrationField(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldTestMigrationField,
|
||||
})
|
||||
}
|
||||
if iu.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@ -1514,20 +1493,6 @@ func (iuo *ItemUpdateOne) ClearSoldNotes() *ItemUpdateOne {
|
|||
return iuo
|
||||
}
|
||||
|
||||
// SetTestMigrationField sets the "test_migration_field" field.
|
||||
func (iuo *ItemUpdateOne) SetTestMigrationField(s string) *ItemUpdateOne {
|
||||
iuo.mutation.SetTestMigrationField(s)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillableTestMigrationField sets the "test_migration_field" field if the given value is not nil.
|
||||
func (iuo *ItemUpdateOne) SetNillableTestMigrationField(s *string) *ItemUpdateOne {
|
||||
if s != nil {
|
||||
iuo.SetTestMigrationField(*s)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (iuo *ItemUpdateOne) SetGroupID(id uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.SetGroupID(id)
|
||||
|
@ -2080,13 +2045,6 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
|
|||
Column: item.FieldSoldNotes,
|
||||
})
|
||||
}
|
||||
if value, ok := iuo.mutation.TestMigrationField(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldTestMigrationField,
|
||||
})
|
||||
}
|
||||
if iuo.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
|
|
@ -159,7 +159,6 @@ var (
|
|||
{Name: "sold_to", Type: field.TypeString, Nullable: true},
|
||||
{Name: "sold_price", Type: field.TypeFloat64, Default: 0},
|
||||
{Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "test_migration_field", Type: field.TypeString, Default: "test-migration-value"},
|
||||
{Name: "group_items", Type: field.TypeUUID},
|
||||
{Name: "location_items", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
|
@ -171,13 +170,13 @@ var (
|
|||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "items_groups_items",
|
||||
Columns: []*schema.Column{ItemsColumns[23]},
|
||||
Columns: []*schema.Column{ItemsColumns[22]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "items_locations_items",
|
||||
Columns: []*schema.Column{ItemsColumns[24]},
|
||||
Columns: []*schema.Column{ItemsColumns[23]},
|
||||
RefColumns: []*schema.Column{LocationsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
|
|
|
@ -3433,7 +3433,6 @@ type ItemMutation struct {
|
|||
sold_price *float64
|
||||
addsold_price *float64
|
||||
sold_notes *string
|
||||
test_migration_field *string
|
||||
clearedFields map[string]struct{}
|
||||
group *uuid.UUID
|
||||
clearedgroup bool
|
||||
|
@ -4542,42 +4541,6 @@ func (m *ItemMutation) ResetSoldNotes() {
|
|||
delete(m.clearedFields, item.FieldSoldNotes)
|
||||
}
|
||||
|
||||
// SetTestMigrationField sets the "test_migration_field" field.
|
||||
func (m *ItemMutation) SetTestMigrationField(s string) {
|
||||
m.test_migration_field = &s
|
||||
}
|
||||
|
||||
// TestMigrationField returns the value of the "test_migration_field" field in the mutation.
|
||||
func (m *ItemMutation) TestMigrationField() (r string, exists bool) {
|
||||
v := m.test_migration_field
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldTestMigrationField returns the old "test_migration_field" field's value of the Item entity.
|
||||
// If the Item object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *ItemMutation) OldTestMigrationField(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldTestMigrationField is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldTestMigrationField requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldTestMigrationField: %w", err)
|
||||
}
|
||||
return oldValue.TestMigrationField, nil
|
||||
}
|
||||
|
||||
// ResetTestMigrationField resets all changes to the "test_migration_field" field.
|
||||
func (m *ItemMutation) ResetTestMigrationField() {
|
||||
m.test_migration_field = nil
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by id.
|
||||
func (m *ItemMutation) SetGroupID(id uuid.UUID) {
|
||||
m.group = &id
|
||||
|
@ -4837,7 +4800,7 @@ func (m *ItemMutation) Type() string {
|
|||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *ItemMutation) Fields() []string {
|
||||
fields := make([]string, 0, 22)
|
||||
fields := make([]string, 0, 21)
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, item.FieldCreatedAt)
|
||||
}
|
||||
|
@ -4901,9 +4864,6 @@ func (m *ItemMutation) Fields() []string {
|
|||
if m.sold_notes != nil {
|
||||
fields = append(fields, item.FieldSoldNotes)
|
||||
}
|
||||
if m.test_migration_field != nil {
|
||||
fields = append(fields, item.FieldTestMigrationField)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
|
@ -4954,8 +4914,6 @@ func (m *ItemMutation) Field(name string) (ent.Value, bool) {
|
|||
return m.SoldPrice()
|
||||
case item.FieldSoldNotes:
|
||||
return m.SoldNotes()
|
||||
case item.FieldTestMigrationField:
|
||||
return m.TestMigrationField()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
@ -5007,8 +4965,6 @@ func (m *ItemMutation) OldField(ctx context.Context, name string) (ent.Value, er
|
|||
return m.OldSoldPrice(ctx)
|
||||
case item.FieldSoldNotes:
|
||||
return m.OldSoldNotes(ctx)
|
||||
case item.FieldTestMigrationField:
|
||||
return m.OldTestMigrationField(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown Item field %s", name)
|
||||
}
|
||||
|
@ -5165,13 +5121,6 @@ func (m *ItemMutation) SetField(name string, value ent.Value) error {
|
|||
}
|
||||
m.SetSoldNotes(v)
|
||||
return nil
|
||||
case item.FieldTestMigrationField:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetTestMigrationField(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Item field %s", name)
|
||||
}
|
||||
|
@ -5404,9 +5353,6 @@ func (m *ItemMutation) ResetField(name string) error {
|
|||
case item.FieldSoldNotes:
|
||||
m.ResetSoldNotes()
|
||||
return nil
|
||||
case item.FieldTestMigrationField:
|
||||
m.ResetTestMigrationField()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Item field %s", name)
|
||||
}
|
||||
|
|
|
@ -275,10 +275,6 @@ func init() {
|
|||
itemDescSoldNotes := itemFields[16].Descriptor()
|
||||
// item.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save.
|
||||
item.SoldNotesValidator = itemDescSoldNotes.Validators[0].(func(string) error)
|
||||
// itemDescTestMigrationField is the schema descriptor for test_migration_field field.
|
||||
itemDescTestMigrationField := itemFields[17].Descriptor()
|
||||
// item.DefaultTestMigrationField holds the default value on creation for the test_migration_field field.
|
||||
item.DefaultTestMigrationField = itemDescTestMigrationField.Default.(string)
|
||||
// itemDescID is the schema descriptor for id field.
|
||||
itemDescID := itemMixinFields0[0].Descriptor()
|
||||
// item.DefaultID holds the default value on creation for the id field.
|
||||
|
|
|
@ -88,9 +88,6 @@ func (Item) Fields() []ent.Field {
|
|||
field.String("sold_notes").
|
||||
MaxLen(1000).
|
||||
Optional(),
|
||||
|
||||
field.String("test_migration_field").
|
||||
Default("test-migration-value"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,11 +61,13 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
|
|||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
|
||||
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
|
@ -75,6 +77,8 @@ github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
|||
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
|
||||
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
-- disable the enforcement of foreign-keys constraints
|
||||
PRAGMA foreign_keys = off;
|
||||
-- create "new_items" table
|
||||
CREATE TABLE `new_items` (`id` uuid NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `name` text NOT NULL, `description` text NULL, `import_ref` text NULL, `notes` text NULL, `quantity` integer NOT NULL DEFAULT 1, `insured` bool NOT NULL DEFAULT false, `serial_number` text NULL, `model_number` text NULL, `manufacturer` text NULL, `lifetime_warranty` bool NOT NULL DEFAULT false, `warranty_expires` datetime NULL, `warranty_details` text NULL, `purchase_time` datetime NULL, `purchase_from` text NULL, `purchase_price` real NOT NULL DEFAULT 0, `sold_time` datetime NULL, `sold_to` text NULL, `sold_price` real NOT NULL DEFAULT 0, `sold_notes` text NULL, `test_migration_field` text NOT NULL DEFAULT 'test-migration-value', `group_items` uuid NOT NULL, `location_items` uuid NULL, PRIMARY KEY (`id`), CONSTRAINT `items_groups_items` FOREIGN KEY (`group_items`) REFERENCES `groups` (`id`) ON DELETE CASCADE, CONSTRAINT `items_locations_items` FOREIGN KEY (`location_items`) REFERENCES `locations` (`id`) ON DELETE CASCADE);
|
||||
-- copy rows from old table "items" to new temporary table "new_items"
|
||||
INSERT INTO `new_items` (`id`, `created_at`, `updated_at`, `name`, `description`, `import_ref`, `notes`, `quantity`, `insured`, `serial_number`, `model_number`, `manufacturer`, `lifetime_warranty`, `warranty_expires`, `warranty_details`, `purchase_time`, `purchase_from`, `purchase_price`, `sold_time`, `sold_to`, `sold_price`, `sold_notes`, `group_items`, `location_items`) SELECT `id`, `created_at`, `updated_at`, `name`, `description`, `import_ref`, `notes`, `quantity`, `insured`, `serial_number`, `model_number`, `manufacturer`, `lifetime_warranty`, `warranty_expires`, `warranty_details`, `purchase_time`, `purchase_from`, `purchase_price`, `sold_time`, `sold_to`, `sold_price`, `sold_notes`, `group_items`, `location_items` FROM `items`;
|
||||
-- drop "items" table after copying rows
|
||||
DROP TABLE `items`;
|
||||
-- rename temporary table "new_items" to "items"
|
||||
ALTER TABLE `new_items` RENAME TO `items`;
|
||||
-- create index "item_name" to table: "items"
|
||||
CREATE INDEX `item_name` ON `items` (`name`);
|
||||
-- create index "item_manufacturer" to table: "items"
|
||||
CREATE INDEX `item_manufacturer` ON `items` (`manufacturer`);
|
||||
-- create index "item_model_number" to table: "items"
|
||||
CREATE INDEX `item_model_number` ON `items` (`model_number`);
|
||||
-- create index "item_serial_number" to table: "items"
|
||||
CREATE INDEX `item_serial_number` ON `items` (`serial_number`);
|
||||
-- enable back the enforcement of foreign-keys constraints
|
||||
PRAGMA foreign_keys = on;
|
|
@ -1,3 +1,2 @@
|
|||
h1:iT4/mowRSTJS2cBVne40fhGw9l4NVFeb6LBsXO+WSWA=
|
||||
20220924230033_init.sql h1:NIjwWnwupwH/EyZC5tZnA/dmff1vMhG2I3EiVQQUNbA=
|
||||
20220924230050_init.sql h1:PRr2ZtlBT9kaYk+0JjvKE5FuPe7pK8U0cXGRjbxeaYE=
|
||||
h1:A58dgWs4yGTcWkHBZwIedtCwK1LIWHYxqB5uKQ40f6E=
|
||||
20220928001319_init.sql h1:KOJZuCHJ5dTHHwVDGgAWyUFahBXqGtmuv4d+rxwpuX0=
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue