Skip to content

Commit a1a55aa

Browse files
committed
fix: migrations
1 parent 16aa4b3 commit a1a55aa

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

internal/ledger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func shortenFeature(feature string) string {
179179

180180
type Configuration struct {
181181
Bucket string `json:"bucket" bun:"bucket,type:varchar(255)"`
182-
Metadata metadata.Metadata `json:"metadata" bun:"metadata,type:jsonb"`
182+
Metadata metadata.Metadata `json:"metadata" bun:"metadata,type:jsonb,nullzero"`
183183
Features FeatureSet `json:"features" bun:"features,type:jsonb"`
184184
}
185185

internal/storage/driver/migrations.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ func GetMigrator() *migrations.Migrator {
200200
})
201201
},
202202
},
203+
migrations.Migration{
204+
Name: "set default metadata on ledgers",
205+
Up: func(ctx context.Context, db bun.IDB) error {
206+
return db.RunInTx(ctx, &sql.TxOptions{}, func(ctx context.Context, tx bun.Tx) error {
207+
_, err := tx.ExecContext(ctx, `
208+
alter table _system.ledgers
209+
alter column metadata set default '{}'::jsonb;
210+
`)
211+
return err
212+
})
213+
},
214+
},
203215
)
204216

205217
return migrator

0 commit comments

Comments
 (0)