In this PR: - remove old versions upgrade commands - add a 0.40 upgrade command to loop over all INACTIVE workspaces and either: update to SUSPENDED (if workspaceSchema exists), update them to SUSPENDED + deletedAt (if workspaceSchema does not exist anymore) Note: why updating the deleted one to SUSPENDED? Because I plan to remove INACTIVE case in the enum in 0.41 Tests made on production like database: - dry-mode - singleWorkspaceId - 3 cases : suspended, deleted+suspended, deleted+suspended+delete all data
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { Logger } from '@nestjs/common';
|
|
|
|
interface CommandLoggerOptions {
|
|
verbose?: boolean;
|
|
constructorName: string;
|
|
}
|
|
|
|
export const isCommandLogger = (
|
|
logger: Logger | CommandLogger,
|
|
): logger is CommandLogger => {
|
|
return typeof logger['setVerbose'] === 'function';
|
|
};
|
|
|
|
export class CommandLogger {
|
|
private logger: Logger;
|
|
private verboseFlag: boolean;
|
|
|
|
constructor(options: CommandLoggerOptions) {
|
|
this.logger = new Logger(options.constructorName);
|
|
this.verboseFlag = options.verbose ?? false;
|
|
}
|
|
|
|
log(message: string, ...optionalParams: [...any, string?]) {
|
|
this.logger.log(message, ...optionalParams);
|
|
}
|
|
|
|
error(message: string, stack?: string, context?: string) {
|
|
this.logger.error(message, stack, context);
|
|
}
|
|
|
|
warn(message: string, ...optionalParams: [...any, string?]) {
|
|
this.logger.warn(message, ...optionalParams);
|
|
}
|
|
|
|
debug(message: string, ...optionalParams: [...any, string?]) {
|
|
this.logger.debug(message, ...optionalParams);
|
|
}
|
|
|
|
verbose(message: string, ...optionalParams: [...any, string?]) {
|
|
if (this.verboseFlag) {
|
|
this.logger.log(message, ...optionalParams);
|
|
}
|
|
}
|
|
|
|
setVerbose(flag: boolean) {
|
|
this.verboseFlag = flag;
|
|
}
|
|
}
|