diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-12 02:52:22 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-12 02:53:52 +0300 |
commit | d05ea66f4bbcf0cc5c8908f3435c68de1b070fa1 (patch) | |
tree | 7c7a769206646f2b81a0eda0680f0be5033a4197 /migrations/20241005143542_init.go |
Начальная версияv0.0.1
Diffstat (limited to 'migrations/20241005143542_init.go')
-rw-r--r-- | migrations/20241005143542_init.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/migrations/20241005143542_init.go b/migrations/20241005143542_init.go new file mode 100644 index 0000000..9487cca --- /dev/null +++ b/migrations/20241005143542_init.go @@ -0,0 +1,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 + }) +} |