Skip to content

Commit c4b5e40

Browse files
committed
fix: missing features migrations for existing ledgers
1 parent 0c39058 commit c4b5e40

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

internal/storage/system/migrations.go

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"database/sql"
66
"github.com/formancehq/go-libs/v2/platform/postgres"
77
"github.com/formancehq/go-libs/v2/time"
8+
"github.com/formancehq/ledger/pkg/features"
89

910
"github.com/formancehq/go-libs/v2/migrations"
1011
"github.com/uptrace/bun"
@@ -201,6 +202,19 @@ func GetMigrator(db *bun.DB, options ...migrations.Option) *migrations.Migrator
201202
})
202203
},
203204
},
205+
migrations.Migration{
206+
Name: "Configure features for old ledgers",
207+
Up: func(ctx context.Context, db bun.IDB) error {
208+
return db.RunInTx(ctx, &sql.TxOptions{}, func(ctx context.Context, tx bun.Tx) error {
209+
_, err := tx.ExecContext(ctx, `
210+
update _system.ledgers
211+
set features = ?
212+
where features is null;
213+
`, features.DefaultFeatures)
214+
return err
215+
})
216+
},
217+
},
204218
)
205219

206220
return migrator

0 commit comments

Comments
 (0)