28 lines
589 B
Go
28 lines
589 B
Go
|
package migrations
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"downloader/internal/core/ports/download_request/sql"
|
||
|
"github.com/uptrace/bun"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error {
|
||
|
_, err := db.Exec(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
db.RegisterModel((*sql.Download)(nil))
|
||
|
_, err = db.NewCreateTable().
|
||
|
Model((*sql.Download)(nil)).
|
||
|
Exec(ctx)
|
||
|
return err
|
||
|
}, func(ctx context.Context, db *bun.DB) error {
|
||
|
_, err := db.NewDropTable().
|
||
|
Model((*sql.Download)(nil)).
|
||
|
Exec(ctx)
|
||
|
return err
|
||
|
})
|
||
|
}
|