mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 09:35:41 -05:00
SQL-Migration: add new migration monitoring data to migration details (#22460)
* add new migration details * move migraiton target type enum to utils * address review feedback, refectore, text update * fix variable name * limit and filter migrations list to mi/vm/db
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { DatabaseMigration } from '../api/azure';
|
||||
import { DefaultSettingValue } from '../api/utils';
|
||||
import { FileStorageType, MigrationMode, MigrationTargetType } from '../models/stateMachine';
|
||||
import { AzureResourceKind, DatabaseMigration } from '../api/azure';
|
||||
import { DefaultSettingValue, MigrationTargetType } from '../api/utils';
|
||||
import { FileStorageType, MigrationMode } from '../models/stateMachine';
|
||||
import * as loc from './strings';
|
||||
|
||||
export enum SQLTargetAssetType {
|
||||
@@ -15,6 +15,48 @@ export enum SQLTargetAssetType {
|
||||
SQLDB = 'Microsoft.Sql/servers',
|
||||
}
|
||||
|
||||
export const FileStorageTypeCodes = {
|
||||
FileShare: "FileShare",
|
||||
AzureBlob: "AzureBlob",
|
||||
None: "None",
|
||||
};
|
||||
|
||||
export const BackupTypeCodes = {
|
||||
// Type of backup. The values match the output of a RESTORE HEADERONLY query.
|
||||
Unknown: "Unknown",
|
||||
Database: "Database",
|
||||
TransactionLog: "TransactionLog",
|
||||
File: "File",
|
||||
DifferentialDatabase: "DifferentialDatabase",
|
||||
DifferentialFile: "DifferentialFile",
|
||||
Partial: "Partial",
|
||||
DifferentialPartial: "DifferentialPartial",
|
||||
};
|
||||
|
||||
export const InternalManagedDatabaseRestoreDetailsBackupSetStatusCodes = {
|
||||
None: "None",
|
||||
Skipped: "Skipped",
|
||||
Queued: "Queued",
|
||||
Restoring: "Restoring",
|
||||
Restored: "Restored",
|
||||
};
|
||||
|
||||
export const InternalManagedDatabaseRestoreDetailsStatusCodes = {
|
||||
None: "None", // Something went wrong most likely.
|
||||
Initializing: "Initializing", // Restore is initializing.
|
||||
NotStarted: "NotStarted", // Restore not started
|
||||
SearchingBackups: "SearchingBackups", // Searching for backups
|
||||
Restoring: "Restoring", // Restore is in progress
|
||||
RestorePaused: "RestorePaused", // Restore is paused
|
||||
RestoreCompleted: "RestoreCompleted", // Restore completed for all found log, but there may have more logs coming
|
||||
Waiting: "Waiting", // Waiting for new files to be uploaded or for Complete restore signal.
|
||||
CompletingMigration: "CompletingMigration", // Completing migration
|
||||
Cancelled: "Cancelled", // Restore cancelled.
|
||||
Failed: "Failed", // Restore failed.
|
||||
Completed: "Completed", // Database is restored and recovery is complete.
|
||||
Blocked: "Blocked", // Restore is temporarily blocked: "", awaiting for user to mitigate the issue.
|
||||
};
|
||||
|
||||
export const ParallelCopyTypeCodes = {
|
||||
None: 'None',
|
||||
DynamicRange: 'DynamicRange',
|
||||
@@ -78,7 +120,9 @@ export function formatTime(miliseconds: number): string {
|
||||
if (miliseconds > 0) {
|
||||
// hh:mm:ss
|
||||
const matches = (new Date(miliseconds))?.toUTCString()?.match(/(\d\d:\d\d:\d\d)/) || [];
|
||||
return matches?.length > 0 ? matches[0] : '';
|
||||
return matches?.length > 0
|
||||
? matches[0] ?? ''
|
||||
: '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -118,12 +162,12 @@ export function getMigrationTargetType(migration: DatabaseMigration | undefined)
|
||||
}
|
||||
|
||||
export function getMigrationTargetTypeEnum(migration: DatabaseMigration | undefined): MigrationTargetType | undefined {
|
||||
switch (migration?.type) {
|
||||
case SQLTargetAssetType.SQLMI:
|
||||
switch (migration?.properties?.kind) {
|
||||
case AzureResourceKind.SQLMI:
|
||||
return MigrationTargetType.SQLMI;
|
||||
case SQLTargetAssetType.SQLVM:
|
||||
case AzureResourceKind.SQLVM:
|
||||
return MigrationTargetType.SQLVM;
|
||||
case SQLTargetAssetType.SQLDB:
|
||||
case AzureResourceKind.SQLDB:
|
||||
return MigrationTargetType.SQLDB;
|
||||
default:
|
||||
return undefined;
|
||||
@@ -150,6 +194,24 @@ export function isBlobMigration(migration: DatabaseMigration | undefined): boole
|
||||
return migration?.properties?.backupConfiguration?.sourceLocation?.fileStorageType === FileStorageType.AzureBlob;
|
||||
}
|
||||
|
||||
export function isShirMigration(migration?: DatabaseMigration): boolean {
|
||||
return isLogicalMigration(migration)
|
||||
|| isFileShareMigration(migration);
|
||||
}
|
||||
|
||||
export function isLogicalMigration(migration?: DatabaseMigration): boolean {
|
||||
return migration?.properties?.kind === AzureResourceKind.ORACLETOSQLDB
|
||||
|| migration?.properties?.kind === AzureResourceKind.SQLDB;
|
||||
}
|
||||
|
||||
export function isFileShareMigration(migration?: DatabaseMigration): boolean {
|
||||
return migration?.properties?.backupConfiguration?.sourceLocation?.fileStorageType === FileStorageTypeCodes.FileShare;
|
||||
}
|
||||
|
||||
export function isTargetType(migration?: DatabaseMigration, kind?: string): boolean {
|
||||
return migration?.properties?.kind === kind;
|
||||
}
|
||||
|
||||
export function getMigrationStatus(migration: DatabaseMigration | undefined): string | undefined {
|
||||
return migration?.properties.migrationStatus
|
||||
?? migration?.properties.provisioningState;
|
||||
@@ -167,6 +229,16 @@ export function hasMigrationOperationId(migration: DatabaseMigration | undefined
|
||||
&& migationOperationId.length > 0;
|
||||
}
|
||||
|
||||
export function getMigrationBackupLocation(migration: DatabaseMigration): string | undefined {
|
||||
return migration?.properties?.backupConfiguration?.sourceLocation?.fileShare?.path
|
||||
?? migration?.properties?.backupConfiguration?.sourceLocation?.azureBlob?.blobContainerName
|
||||
?? migration?.properties?.migrationStatusDetails?.blobContainerName;
|
||||
}
|
||||
|
||||
export function getMigrationFullBackupFiles(migration: DatabaseMigration): string | undefined {
|
||||
return migration?.properties?.migrationStatusDetails?.fullBackupSetInfo?.listOfBackupFiles?.map(file => file.fileName).join(',');
|
||||
}
|
||||
|
||||
export function hasRestoreBlockingReason(migration: DatabaseMigration | undefined): boolean {
|
||||
return (migration?.properties.migrationStatusWarnings?.restoreBlockingReason ?? '').length > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user