feat: refactor configuration to include source and target database types
This commit is contained in:
@@ -175,16 +175,3 @@ func logColumnTypes(columnTypes []models.ColumnType, label string) {
|
|||||||
log.Debugf("%+v", col)
|
log.Debugf("%+v", col)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func logSampleRow(
|
|
||||||
schema string,
|
|
||||||
table string,
|
|
||||||
columns []ColumnType,
|
|
||||||
rowValues models.UnknownRowValues,
|
|
||||||
tag string,
|
|
||||||
) {
|
|
||||||
log.Infof("[%s.%s] Sample row: (%s)", schema, table, tag)
|
|
||||||
for i, col := range columns {
|
|
||||||
log.Infof("%s (%T): %v", col.Name(), rowValues[i], rowValues[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
max_parallel_workers: 4
|
max_parallel_workers: 4
|
||||||
|
source_db_type: sqlserver
|
||||||
|
target_db_type: postgres
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
max_extractors: 2
|
max_extractors: 2
|
||||||
|
|||||||
@@ -8,10 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type appConfig struct {
|
type appConfig struct {
|
||||||
SourceDbUrl string
|
SourceDbUrl string
|
||||||
SourceDbType string
|
TargetDbUrl string
|
||||||
TargetDbUrl string
|
|
||||||
TargetDbType string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadEnv() {
|
func loadEnv() {
|
||||||
@@ -29,26 +27,14 @@ func getAppConfig() appConfig {
|
|||||||
log.Fatal("SOURCE_DB_URL environment variable not set")
|
log.Fatal("SOURCE_DB_URL environment variable not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceDbType := os.Getenv("SOURCE_DB_TYPE")
|
|
||||||
if sourceDbType == "" {
|
|
||||||
log.Fatal("SOURCE_DB_TYPE environment variable not set")
|
|
||||||
}
|
|
||||||
|
|
||||||
targetDbUrl := os.Getenv("TARGET_DB_URL")
|
targetDbUrl := os.Getenv("TARGET_DB_URL")
|
||||||
if targetDbUrl == "" {
|
if targetDbUrl == "" {
|
||||||
log.Fatal("TARGET_DB_URL environment variable not set")
|
log.Fatal("TARGET_DB_URL environment variable not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
targetDbType := os.Getenv("TARGET_DB_TYPE")
|
|
||||||
if targetDbType == "" {
|
|
||||||
log.Fatal("TARGET_DB_TYPE environment variable not set")
|
|
||||||
}
|
|
||||||
|
|
||||||
return appConfig{
|
return appConfig{
|
||||||
SourceDbUrl: sourceDbUrl,
|
SourceDbUrl: sourceDbUrl,
|
||||||
SourceDbType: sourceDbType,
|
TargetDbUrl: targetDbUrl,
|
||||||
TargetDbUrl: targetDbUrl,
|
|
||||||
TargetDbType: targetDbType,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,12 +46,16 @@ type Job struct {
|
|||||||
|
|
||||||
type MigrationConfig struct {
|
type MigrationConfig struct {
|
||||||
MaxParallelWorkers int `yaml:"max_parallel_workers"`
|
MaxParallelWorkers int `yaml:"max_parallel_workers"`
|
||||||
|
SourceDbType string `yaml:"source_db_type"`
|
||||||
|
TargetDbType string `yaml:"target_db_type"`
|
||||||
Defaults JobConfig `yaml:"defaults"`
|
Defaults JobConfig `yaml:"defaults"`
|
||||||
Jobs []Job `yaml:"jobs"`
|
Jobs []Job `yaml:"jobs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type rawConfig struct {
|
type rawConfig struct {
|
||||||
MaxParallelWorkers int `yaml:"max_parallel_workers"`
|
MaxParallelWorkers int `yaml:"max_parallel_workers"`
|
||||||
|
SourceDbType string `yaml:"source_db_type"`
|
||||||
|
TargetDbType string `yaml:"target_db_type"`
|
||||||
Defaults JobConfig `yaml:"defaults"`
|
Defaults JobConfig `yaml:"defaults"`
|
||||||
Jobs []yaml.Node `yaml:"jobs"`
|
Jobs []yaml.Node `yaml:"jobs"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user