aboutsummaryrefslogblamecommitdiff
path: root/migrations/20241010175211_session.go
blob: 61dd8e8c134d904ba2e9732237dcef0e1a603064 (plain) (tree)
1
2
3
4
5
6
7
8






                                
                                                       

























                                                                             
package migrations

import (
	"context"
	"fmt"

	"github.com/uptrace/bun"
	"neonxp.ru/go/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
	})
}