53 lines
1.0 KiB
Go
53 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type MigrationJob struct {
|
|
Schema string
|
|
Table string
|
|
PrimaryKey string
|
|
}
|
|
|
|
var migrationJobs []MigrationJob = []MigrationJob{
|
|
{
|
|
Schema: "Red",
|
|
Table: "PUERTO",
|
|
PrimaryKey: "ID_PUERTO",
|
|
},
|
|
}
|
|
|
|
const (
|
|
NumExtractors int = 4
|
|
NumLoaders int = 8
|
|
ChunkSize int = 25000
|
|
QueueSize int = 8
|
|
)
|
|
|
|
func main() {
|
|
configureLog()
|
|
startTime := time.Now()
|
|
log.Info("=== Starting migration ===")
|
|
log.Infof("Number of loaders: %d, Chunk size: %d", NumLoaders, ChunkSize)
|
|
|
|
sourceDb, targetDb, connError := connectToDatabases()
|
|
if connError != nil {
|
|
log.Fatal("Connection error: ", connError)
|
|
}
|
|
|
|
defer sourceDb.Close()
|
|
defer targetDb.Close()
|
|
|
|
for _, job := range migrationJobs {
|
|
log.Infof(">>> Processing job: %s.%s <<<", job.Schema, job.Table)
|
|
processMigrationJob(sourceDb, targetDb, job)
|
|
}
|
|
|
|
totalDuration := time.Since(startTime)
|
|
log.Infof("=== Migration completed successfully! ===")
|
|
log.Infof("Total migration time: %v", totalDuration)
|
|
}
|