summaryrefslogtreecommitdiff
path: root/migrations
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-12-09 01:07:15 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-12-09 01:07:15 +0300
commit34ccc98a942098faefb5f4211b215ff9ccc7ad0e (patch)
tree7696ab4d7c8d9fb09c7e2575d482517f68824ae3 /migrations
Начальный
Diffstat (limited to 'migrations')
-rw-r--r--migrations/20241005143542_init.go29
-rw-r--r--migrations/main.go7
2 files changed, 36 insertions, 0 deletions
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
+ })
+}
diff --git a/migrations/main.go b/migrations/main.go
new file mode 100644
index 0000000..f7346fb
--- /dev/null
+++ b/migrations/main.go
@@ -0,0 +1,7 @@
+package migrations
+
+import (
+ "github.com/uptrace/bun/migrate"
+)
+
+var Migrations = migrate.NewMigrations()