feat: remove unused column type logging and streamline migration job processing
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/microsoft/go-mssqldb"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ var migrationJobs []MigrationJob = []MigrationJob{
|
|||||||
func main() {
|
func main() {
|
||||||
configureLog()
|
configureLog()
|
||||||
log.Info("Starting migration...")
|
log.Info("Starting migration...")
|
||||||
log.Debugf("Migration jobs: %+v", migrationJobs)
|
// log.Debugf("Migration jobs: %+v", migrationJobs)
|
||||||
|
|
||||||
sourceDb, targetDb, connError := connectToDatabases()
|
sourceDb, targetDb, connError := connectToDatabases()
|
||||||
if connError != nil {
|
if connError != nil {
|
||||||
@@ -31,22 +30,9 @@ func main() {
|
|||||||
defer targetDb.Close()
|
defer targetDb.Close()
|
||||||
|
|
||||||
for _, job := range migrationJobs {
|
for _, job := range migrationJobs {
|
||||||
sourceColTypes, targetColTypes, err := GetColumnTypes(sourceDb, targetDb, job)
|
log.Infof("Processing job: %+v", job)
|
||||||
if err != nil {
|
processMigrationJob(sourceDb, targetDb, job)
|
||||||
log.Fatal("Unexpected error: ", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
logColumnTypes(sourceColTypes, "Source col types")
|
|
||||||
logColumnTypes(targetColTypes, "Target col types")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Migration completed successfully!")
|
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
27
cmd/go_migrate/process.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user