aboutsummaryrefslogtreecommitdiff
path: root/migrations/20241005143542_init.go
blob: 9487cca5b714c1fb6bb3576ba79b871c75f9e378 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package migrations

import (
	"context"
	"fmt"

	"github.com/uptrace/bun"
	"go.neonxp.ru/framework/pkg/model"
)

//nolint:gochecknoinits
func init() {
	Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error {
		fmt.Print(" [up migration] ")

		if _, err := db.NewCreateTable().Model((*model.User)(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((*model.User)(nil)).Exec(ctx); err != nil {
			return err
		}

		return nil
	})
}