Skip to content

Commit

Permalink
fix: migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 22, 2024
1 parent 16aa4b3 commit a1a55aa
Show file tree
Hide file tree
Showing 2 changed files with 13 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
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: "set default metadata on ledgers",
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 a1a55aa

Please sign in to comment.