From 749f13d9bf60d6b57a674d60335429ef3a44923f Mon Sep 17 00:00:00 2001 From: siyang yao Date: Wed, 1 Feb 2023 11:23:21 -0800 Subject: [PATCH] [SQL-Migration] collation errorcode (#21797) --- extensions/sql-migration/src/constants/helper.ts | 5 +++++ extensions/sql-migration/src/constants/strings.ts | 11 +++++++---- .../sql-migration/src/wizard/targetSelectionPage.ts | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/extensions/sql-migration/src/constants/helper.ts b/extensions/sql-migration/src/constants/helper.ts index 30ebd940b7..311108ce84 100644 --- a/extensions/sql-migration/src/constants/helper.ts +++ b/extensions/sql-migration/src/constants/helper.ts @@ -44,6 +44,11 @@ export const LoginMigrationStatusCodes = { Failed: 'Failed', }; +export const ValidationErrorCodes = { + // TODO: adding other error codes for troubleshooting + SqlInfoValidationFailed: '2056' +}; + const _dateFormatter = new Intl.DateTimeFormat( undefined, { year: 'numeric', diff --git a/extensions/sql-migration/src/constants/strings.ts b/extensions/sql-migration/src/constants/strings.ts index c86848789f..559d27dfe5 100644 --- a/extensions/sql-migration/src/constants/strings.ts +++ b/extensions/sql-migration/src/constants/strings.ts @@ -408,9 +408,10 @@ export function SQL_TARGET_CONNECTION_DUPLICATE_TARGET_MAPPING( ): string { return localize( 'sql.migration.wizard.target.mapping.error.duplicate', - "Database mapping error. Target database '{0}' cannot be selected to as a migration target for database '{1}'. Target database '${targetDatabaseName}' is already selected as a migration target for database '{2}'. Please select a different target database.", + "Database mapping error. Target database '{0}' cannot be selected to as a migration target for database '{1}'. Target database '{2}' is already selected as a migration target for database '{3}'. Please select a different target database.", targetDatabaseName, sourceDatabaseName, + targetDatabaseName, mappedSourceDatabaseName); } @@ -418,19 +419,21 @@ export function SQL_TARGET_CONNECTION_DUPLICATE_TARGET_MAPPING( export function SQL_TARGET_CONNECTION_SOURCE_NOT_MAPPED(sourceDatabaseName: string): string { return localize( 'sql.migration.wizard.target.source.mapping.error', - "Database mapping error. Source database '{0}' is not mapped to a target database. Please select a target database to migrate to.", + "Database mapping error. Source database '{0}' is not mapped to a target database. Please select a target database to migrate to.", sourceDatabaseName); } -//`Database mapping error. Source database ({0}) collation ({1}) does not match target database ({2}) collation ({3}). Please select a target database with the same collation to the source database.` +//`A mapping error (Error code: {0}) was found between '{1}' and '{2}' databases. The source database collation '{3}' does not match the target database collation '{4}'. Please select or re-create a target database with the same collation as the source database.` export function SQL_TARGET_SOURCE_COLLATION_NOT_SAME( + errorCode: string, sourceDatabaseName: string, targetDatabaseName: string, sourceDatabaseCollation: string | undefined, targetDatabaseCollation: string | undefined): string { return localize( 'sql.migration.wizard.target.source.collation.error', - "A mapping error was found between '{0}' and '{1}' databases. The source database collation '{2}' does not match the target database collation '{3}'. Please select or re-create a target database with the same collation as the source database.", + "Database mapping error (Error code: {0}) was found between '{1}' and '{2}' databases. The source database collation '{3}' does not match the target database collation '{4}'. Please select or re-create a target database with the same collation as the source database.", + errorCode, sourceDatabaseName, targetDatabaseName, sourceDatabaseCollation, diff --git a/extensions/sql-migration/src/wizard/targetSelectionPage.ts b/extensions/sql-migration/src/wizard/targetSelectionPage.ts index 7ba6a149df..9ac75c2803 100644 --- a/extensions/sql-migration/src/wizard/targetSelectionPage.ts +++ b/extensions/sql-migration/src/wizard/targetSelectionPage.ts @@ -17,6 +17,7 @@ import { AzureSqlDatabaseServer, getVMInstanceView, SqlVMServer } from '../api/a import { collectTargetDatabaseInfo, TargetDatabaseInfo } from '../api/sqlUtils'; import { MigrationLocalStorage, MigrationServiceContext } from '../models/migrationLocalStorage'; import { TdeMigrationDialog } from '../dialog/tdeConfiguration/tdeMigrationDialog'; +import { ValidationErrorCodes } from '../constants/helper'; const TDE_MIGRATION_BUTTON_INDEX = 1; @@ -1167,6 +1168,7 @@ export class TargetSelectionPage extends MigrationWizardPage { if (!this._isCollationSame(sourceDatabaseCollation, targetDatabaseCollation)) { collationErrors.push( constants.SQL_TARGET_SOURCE_COLLATION_NOT_SAME( + ValidationErrorCodes.SqlInfoValidationFailed, sourceDatabaseName, targetDatabaseName, sourceDatabaseCollation,