mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
added migration route
This commit is contained in:
@@ -6,16 +6,18 @@ import (
|
||||
"github.com/go-pg/pg/v10"
|
||||
)
|
||||
|
||||
func Start(conn *pg.DB) {
|
||||
func Start(conn *pg.DB) error {
|
||||
apiMigration := migrations.ApiMigration{Db: conn}
|
||||
usersMigration := migrations.UsersMigration{Db: conn}
|
||||
walletsMigration := migrations.WalletsMigration{Db: conn}
|
||||
transactionTypesMigration := migrations.TransactionTypesMigration{Db: conn}
|
||||
transactionsMigration := migrations.TransactionsMigration{Db: conn}
|
||||
|
||||
apiMigration.Create()
|
||||
usersMigration.Create()
|
||||
walletsMigration.Create()
|
||||
transactionTypesMigration.Create()
|
||||
transactionsMigration.Create()
|
||||
err := apiMigration.Create()
|
||||
err = usersMigration.Create()
|
||||
err = walletsMigration.Create()
|
||||
err = transactionTypesMigration.Create()
|
||||
err = transactionsMigration.Create()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type ApiMigration struct {
|
||||
Db *pg.DB
|
||||
}
|
||||
|
||||
func (am *ApiMigration) Create() {
|
||||
func (am *ApiMigration) Create() error {
|
||||
models := []interface{}{
|
||||
(*models.ApiModel)(nil),
|
||||
}
|
||||
@@ -24,8 +24,10 @@ func (am *ApiMigration) Create() {
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error Creating Table: %s", err)
|
||||
return err
|
||||
} else {
|
||||
fmt.Println("Table created successfully")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type TransactionTypesMigration struct {
|
||||
Db *pg.DB
|
||||
}
|
||||
|
||||
func (am *TransactionTypesMigration) Create() {
|
||||
func (am *TransactionTypesMigration) Create() error {
|
||||
models := []interface{}{
|
||||
(*models.TransactionType)(nil),
|
||||
}
|
||||
@@ -25,8 +25,10 @@ func (am *TransactionTypesMigration) Create() {
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error Creating Table: %s", err)
|
||||
return err
|
||||
} else {
|
||||
fmt.Println("Table created successfully")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type TransactionsMigration struct {
|
||||
Db *pg.DB
|
||||
}
|
||||
|
||||
func (am *TransactionsMigration) Create() {
|
||||
func (am *TransactionsMigration) Create() error {
|
||||
models := []interface{}{
|
||||
(*models.Transaction)(nil),
|
||||
}
|
||||
@@ -25,8 +25,10 @@ func (am *TransactionsMigration) Create() {
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error Creating Table: %s", err)
|
||||
return err
|
||||
} else {
|
||||
fmt.Println("Table created successfully")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type UsersMigration struct {
|
||||
Db *pg.DB
|
||||
}
|
||||
|
||||
func (am *UsersMigration) Create() {
|
||||
func (am *UsersMigration) Create() error {
|
||||
models := []interface{}{
|
||||
(*models.User)(nil),
|
||||
}
|
||||
@@ -24,8 +24,10 @@ func (am *UsersMigration) Create() {
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error Creating Table: %s", err)
|
||||
return err
|
||||
} else {
|
||||
fmt.Println("Table created successfully")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type WalletsMigration struct {
|
||||
Db *pg.DB
|
||||
}
|
||||
|
||||
func (am *WalletsMigration) Create() {
|
||||
func (am *WalletsMigration) Create() error {
|
||||
models := []interface{}{
|
||||
(*models.Wallet)(nil),
|
||||
}
|
||||
@@ -25,8 +25,10 @@ func (am *WalletsMigration) Create() {
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error Creating Table: %s", err)
|
||||
return err
|
||||
} else {
|
||||
fmt.Println("Table created successfully")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user