Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: retrieving migration uuid early in the export schema phase #2128

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions yb-voyager/cmd/exportSchema.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ func exportSchema() error {
utils.PrintAndLog("Schema is not exported yet. Ignoring --start-clean flag.\n\n")
}
CreateMigrationProjectIfNotExists(source.DBType, exportDir)

err := retrieveMigrationUUID()
if err != nil {
log.Errorf("failed to get migration UUID: %v", err)
return fmt.Errorf("failed to get migration UUID: %w", err)
}

utils.PrintAndLog("export of schema for source type as '%s'\n", source.DBType)
// Check connection with source database.
err := source.DB().Connect()
err = source.DB().Connect()
if err != nil {
log.Errorf("failed to connect to the source db: %s", err)
return fmt.Errorf("failed to connect to the source db: %w", err)
Expand Down Expand Up @@ -153,12 +158,6 @@ func exportSchema() error {
}
}

err = retrieveMigrationUUID()
if err != nil {
log.Errorf("failed to get migration UUID: %v", err)
return fmt.Errorf("failed to get migration UUID: %w", err)
}

exportSchemaStartEvent := createExportSchemaStartedEvent()
controlPlane.ExportSchemaStarted(&exportSchemaStartEvent)

Expand Down
9 changes: 5 additions & 4 deletions yb-voyager/cmd/importData.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ func importDataCommandFn(cmd *cobra.Command, args []string) {
utils.ErrExit("Failed to get migration status record: %s", err)
}

err = retrieveMigrationUUID()
if err != nil {
utils.ErrExit("failed to get migration UUID: %w", err)
}

// Check if target DB has the required permissions
if tconf.RunGuardrailsChecks {
checkImportDataPermissions()
Expand Down Expand Up @@ -470,10 +475,6 @@ func updateTargetConfInMigrationStatus() {
}

func importData(importFileTasks []*ImportFileTask) {
err := retrieveMigrationUUID()
if err != nil {
utils.ErrExit("failed to get migration UUID: %w", err)
}

if (importerRole == TARGET_DB_IMPORTER_ROLE || importerRole == IMPORT_FILE_ROLE) && (tconf.EnableUpsert) {
if !utils.AskPrompt(color.RedString("WARNING: Ensure that tables on target YugabyteDB do not have secondary indexes. " +
Expand Down
4 changes: 4 additions & 0 deletions yb-voyager/cmd/importDataFileCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ var importDataFileCmd = &cobra.Command{
dataStore = datastore.NewDataStore(dataDir)
importFileTasks := prepareImportFileTasks()
prepareForImportDataCmd(importFileTasks)
err := retrieveMigrationUUID()
if err != nil {
utils.ErrExit("failed to get migration UUID: %w", err)
}
importData(importFileTasks)
packAndSendImportDataFilePayload(COMPLETE)

Expand Down