framework/migrations/20241010175211_session.go

35 lines
613 B
Go
Raw Permalink Normal View History

2024-10-12 02:52:22 +03:00
package migrations
import (
"context"
"fmt"
"github.com/uptrace/bun"
"go.neonxp.ru/framework/pkg/middleware/session"
)
//nolint:gochecknoinits
func init() {
Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error {
fmt.Print(" [up migration] ")
if _, err := db.NewCreateTable().
Model((*session.Model)(nil)).
Exec(ctx); err != nil {
return err
}
return nil
}, func(ctx context.Context, db *bun.DB) error {
fmt.Print(" [down migration] ")
if _, err := db.NewDropTable().
Model((*session.Model)(nil)).
Exec(ctx); err != nil {
return err
}
return nil
})
}