mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 14:18:12 +00:00
register controller
This commit is contained in:
31
pkg/migrate/migrations/users.go
Normal file
31
pkg/migrate/migrations/users.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"wallet-api/pkg/models"
|
||||
|
||||
"github.com/go-pg/pg/v10"
|
||||
"github.com/go-pg/pg/v10/orm"
|
||||
)
|
||||
|
||||
type UsersMigration struct {
|
||||
Db *pg.DB
|
||||
}
|
||||
|
||||
func (am *UsersMigration) Create() {
|
||||
models := []interface{}{
|
||||
(*models.UserModel)(nil),
|
||||
}
|
||||
|
||||
for _, model := range models {
|
||||
err := am.Db.Model(model).CreateTable(&orm.CreateTableOptions{
|
||||
IfNotExists: true,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error Creating Table: %s", err)
|
||||
} else {
|
||||
fmt.Println("Table created successfully")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user