Skip to content

Commit

Permalink
add back automatic migrations
Browse files Browse the repository at this point in the history
These weren't working with the test suite due to concurrency issues but it seems running them on the start hook mitigates this.
  • Loading branch information
Southclaws committed Oct 21, 2023
1 parent 64bbe5b commit ab06c9b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ func newEntClient(lc fx.Lifecycle, db *sql.DB) (*ent.Client, error) {
}

lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
// Run create-only migrations after initialisation.
// This is done in tests and scripts too.
if err := client.Schema.Create(ctx); err != nil {
return fault.Wrap(err, fctx.With(ctx))
}

return nil
},
OnStop: func(ctx context.Context) error {
defer cancel()

Expand Down

0 comments on commit ab06c9b

Please sign in to comment.