Files
wallet-go-api/pkg/migrate/migrations/transactions.go
2021-05-16 17:43:58 +02:00

33 lines
565 B
Go

package migrations
import (
"fmt"
"log"
"wallet-api/pkg/models"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
)
type TransactionsMigration struct {
Db *pg.DB
}
func (am *TransactionsMigration) Create() {
models := []interface{}{
(*models.Transaction)(nil),
}
for _, model := range models {
err := am.Db.Model(model).CreateTable(&orm.CreateTableOptions{
IfNotExists: false,
FKConstraints: true,
})
if err != nil {
log.Printf("Error Creating Table: %s", err)
} else {
fmt.Println("Table created successfully")
}
}
}