summaryrefslogblamecommitdiff
path: root/migrations/20241005143542_init.go
blob: f15b7c10f0ed182eda03e67b3bee1a8c1d75467d (plain) (tree)




























                                                                                                   
package migrations

import (
	"context"
	"fmt"

	"git.neonxp.ru/neonxp/guessr/pkg/model"
	"github.com/uptrace/bun"
)

//nolint:gochecknoinits
func init() {
	Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error {
		fmt.Print(" [up migration] ")
		if _, err := db.NewCreateTable().Model((*model.Place)(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.Place)(nil)).Exec(ctx); err != nil {
			return err
		}

		return nil
	})
}