Post-Migrator/services/migration/post-result.go

27 lines
744 B
Go
Raw Normal View History

2024-05-19 21:00:33 +00:00
package migration
import "database/sql"
type PostResult struct {
WordpressId int
SlowtwitchId int
OldUrl string
OldUrlStatus int
NewUrl string
IsSuccess bool
ErrorMessage string
}
func CreatePostResult(parameters PostResult, db *sql.DB) (int, error) {
2024-05-20 01:35:53 +00:00
result, err := db.Exec("insert into PostResults (WordpressId, SlowtwitchId, OldUrl, OldUrlStatus, NewUrl, IsSuccess, ErrorMessage) values (?, ?, ?, ?, ?, ?, ?)", parameters.WordpressId, parameters.SlowtwitchId, parameters.OldUrl, parameters.OldUrlStatus, parameters.NewUrl, parameters.IsSuccess, parameters.ErrorMessage)
2024-05-19 21:00:33 +00:00
if err != nil {
return 0, err
} else {
id, err := result.LastInsertId()
if err != nil {
return 0, err
}
return int(id), nil
}
}