aboutsummaryrefslogtreecommitdiff
path: root/migrations/20241010175211_session.go
diff options
context:
space:
mode:
Diffstat (limited to 'migrations/20241010175211_session.go')
-rw-r--r--migrations/20241010175211_session.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/migrations/20241010175211_session.go b/migrations/20241010175211_session.go
new file mode 100644
index 0000000..8cb91ea
--- /dev/null
+++ b/migrations/20241010175211_session.go
@@ -0,0 +1,34 @@
+package migrations
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/uptrace/bun"
+ "go.neonxp.ru/framework/pkg/middleware/session"
+)
+
+//nolint:gochecknoinits
+func init() {
+ Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error {
+ fmt.Print(" [up migration] ")
+
+ if _, err := db.NewCreateTable().
+ Model((*session.Model)(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((*session.Model)(nil)).
+ Exec(ctx); err != nil {
+ return err
+ }
+
+ return nil
+ })
+}