Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 22, 2024
1 parent 6568f9f commit 79c5bf7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func shortenFeature(feature string) string {

type Configuration struct {
Bucket string `json:"bucket" bun:"bucket,type:varchar(255)"`
Metadata metadata.Metadata `json:"metadata" bun:"metadata,type:jsonb"`
Metadata metadata.Metadata `json:"metadata" bun:"metadata,type:jsonb,nullzero"`
Features FeatureSet `json:"features" bun:"features,type:jsonb"`
}

Expand Down
2 changes: 2 additions & 0 deletions internal/storage/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (d *Driver) UpdateLedgerMetadata(ctx context.Context, name string, m metada
Set("metadata = metadata || ?", m).
Where("name = ?", name).
Exec(ctx)

return err
}

Expand All @@ -124,6 +125,7 @@ func (d *Driver) ListLedgers(ctx context.Context, q ledgercontroller.ListLedgers
}

func (d *Driver) GetLedger(ctx context.Context, name string) (*ledger.Ledger, error) {

ret := &ledger.Ledger{}
if err := d.db.NewSelect().
Model(ret).
Expand Down
12 changes: 12 additions & 0 deletions internal/storage/driver/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ func GetMigrator() *migrations.Migrator {
})
},
},
migrations.Migration{
Name: "add default on ledgers metadata",
Up: func(ctx context.Context, db bun.IDB) error {
return db.RunInTx(ctx, &sql.TxOptions{}, func(ctx context.Context, tx bun.Tx) error {
_, err := tx.ExecContext(ctx, `
alter table _system.ledgers
alter column metadata set default '{}'::jsonb;
`)
return err
})
},
},
)

return migrator
Expand Down

0 comments on commit 79c5bf7

Please sign in to comment.