feat: remove unused column type logging and streamline migration job processing

This commit is contained in:
2026-04-06 10:48:56 -05:00
parent 828fc57121
commit c49ff65b1d
2 changed files with 30 additions and 17 deletions

View File

@@ -1,7 +1,6 @@
package main
import (
_ "github.com/microsoft/go-mssqldb"
log "github.com/sirupsen/logrus"
)
@@ -20,7 +19,7 @@ var migrationJobs []MigrationJob = []MigrationJob{
func main() {
configureLog()
log.Info("Starting migration...")
log.Debugf("Migration jobs: %+v", migrationJobs)
// log.Debugf("Migration jobs: %+v", migrationJobs)
sourceDb, targetDb, connError := connectToDatabases()
if connError != nil {
@@ -31,22 +30,9 @@ func main() {
defer targetDb.Close()
for _, job := range migrationJobs {
sourceColTypes, targetColTypes, err := GetColumnTypes(sourceDb, targetDb, job)
if err != nil {
log.Fatal("Unexpected error: ", err)
}
logColumnTypes(sourceColTypes, "Source col types")
logColumnTypes(targetColTypes, "Target col types")
log.Infof("Processing job: %+v", job)
processMigrationJob(sourceDb, targetDb, job)
}
log.Info("Migration completed successfully!")
}
func logColumnTypes(columnTypes []ColumnType, label string) {
log.Info(label)
for _, col := range columnTypes {
log.Infof("%+v", col)
}
}

27
cmd/go_migrate/process.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"database/sql"
"github.com/jackc/pgx/v5/pgxpool"
_ "github.com/microsoft/go-mssqldb"
log "github.com/sirupsen/logrus"
)
func processMigrationJob(sourceDb *sql.DB, targetDb *pgxpool.Pool, job MigrationJob) {
sourceColTypes, targetColTypes, err := GetColumnTypes(sourceDb, targetDb, job)
if err != nil {
log.Fatal("Unexpected error: ", err)
}
logColumnTypes(sourceColTypes, "Source col types")
logColumnTypes(targetColTypes, "Target col types")
}
func logColumnTypes(columnTypes []ColumnType, label string) {
log.Info(label)
for _, col := range columnTypes {
log.Infof("%+v", col)
}
}