Started working on the blogs

This commit is contained in:
cdricms
2025-02-21 17:49:42 +01:00
parent de828d4c13
commit 7a97961fef
9 changed files with 178 additions and 79 deletions

View File

@@ -0,0 +1,25 @@
package migrations
import (
"context"
"fmt"
"fr.latosa-escrima/core/models"
"github.com/uptrace/bun"
)
func init() {
Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error {
fmt.Print(" [up migration] ")
_, err := db.NewDropColumn().
Model((*models.Blog)(nil)).
Column("href").
Exec(ctx)
_, err = db.Exec(`ALTER TABLE blogs RENAME COLUMN label TO title;
ALTER TABLE blogs ALTER COLUMN title SET NOT NULL;`)
return err
}, func(ctx context.Context, db *bun.DB) error {
fmt.Print(" [down migration] ")
return nil
})
}