Skip to content

Commit 6632ee8

Browse files
committed
feat(CI - Github Actions): added build new release
1 parent ab52161 commit 6632ee8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

main.go

+36
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"database/sql"
5+
"fmt"
56

67
"github.com/LuisMarchio03/golang_migration_system/internal/config"
78
"github.com/LuisMarchio03/golang_migration_system/internal/exec"
@@ -56,3 +57,38 @@ func ExecRunMigrations(db *sql.DB, migrationsDir string) error {
5657
}
5758
return nil
5859
}
60+
61+
func main() {
62+
// Aqui você pode chamar suas funções conforme necessário
63+
db, err := ExecConfigDB("mysql", config.Cfg{}, "migrationsDir")
64+
if err != nil {
65+
fmt.Println("Error configuring database:", err)
66+
return
67+
}
68+
69+
// Exemplo: gerar migrações
70+
schema := config.Schema{
71+
TableName: "users",
72+
Fields: map[string]string{
73+
"id": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY",
74+
"username": "VARCHAR(50) NOT NULL",
75+
"email": "VARCHAR(100) NOT NULL",
76+
"created_at": "TIMESTAMP DEFAULT CURRENT_TIMESTAMP",
77+
"updated_at": "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
78+
},
79+
}
80+
migrationFileName, err := ExecGenerateMigration(schema)
81+
if err != nil {
82+
fmt.Println("Error generating migration:", err)
83+
return
84+
}
85+
fmt.Println("Migration generated successfully:", migrationFileName)
86+
87+
// Exemplo: executar migrações
88+
err = ExecRunMigrations(db, "migrationsDir")
89+
if err != nil {
90+
fmt.Println("Error executing migrations:", err)
91+
return
92+
}
93+
fmt.Println("Migrations completed successfully.")
94+
}

0 commit comments

Comments
 (0)