diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-08 03:43:08 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-08 03:50:53 +0300 |
commit | e849e705c30cceec3cf7336a21bed96c8a911e90 (patch) | |
tree | 93f559bcd4cf3e53193930d112e564a2b7462ac8 /migrations | |
parent | 3ee654f6fb3cdf119630bfba8066c96ec26428c3 (diff) |
Добавил рейтинг
Добавил страницу топа
Добавил rss/xml/json feed
Diffstat (limited to 'migrations')
-rw-r--r-- | migrations/20241007210540_2_rating.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/migrations/20241007210540_2_rating.go b/migrations/20241007210540_2_rating.go new file mode 100644 index 0000000..06acb72 --- /dev/null +++ b/migrations/20241007210540_2_rating.go @@ -0,0 +1,33 @@ +package migrations + +import ( + "context" + "fmt" + + "github.com/uptrace/bun" + "sh.org.ru/pkg/model" +) + +func init() { + Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error { + fmt.Print(" [up migration] ") + if _, err := db.NewAddColumn(). + Model((*model.Quote)(nil)). + ColumnExpr("rating INT NOT NULL DEFAULT '0'"). + Exec(ctx); err != nil { + return err + } + + return nil + }, func(ctx context.Context, db *bun.DB) error { + fmt.Print(" [down migration] ") + if _, err := db.NewDropColumn(). + Model((*model.Quote)(nil)). + Column("rating"). + Exec(ctx); err != nil { + return err + } + + return nil + }) +} |