31 lines
578 B
Go
31 lines
578 B
Go
|
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
|
||
|
})
|
||
|
}
|