From 34ccc98a942098faefb5f4211b215ff9ccc7ad0e Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Mon, 9 Dec 2024 01:07:15 +0300 Subject: Начальный MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/20241005143542_init.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 migrations/20241005143542_init.go (limited to 'migrations/20241005143542_init.go') diff --git a/migrations/20241005143542_init.go b/migrations/20241005143542_init.go new file mode 100644 index 0000000..f15b7c1 --- /dev/null +++ b/migrations/20241005143542_init.go @@ -0,0 +1,29 @@ +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 + }) +} -- cgit v1.2.3