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

Add a warning on vip export when exporting a MyDumper SQL dump #2130

Merged
merged 1 commit into from
Nov 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
2 changes: 2 additions & 0 deletions src/commands/export-sql.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ export type AppBackupAndJobStatusQuery = {
environments?: Array< {
__typename?: 'AppEnvironment';
id?: number | null;
backupsSqlDumpTool?: string | null;
latestBackup?: {
__typename?: 'Backup';
id?: number | null;
type?: string | null;
size?: number | null;
filename?: string | null;
sqlDumpTool?: string | null;
createdAt?: string | null;
} | null;
jobs?: Array<
Expand Down
23 changes: 21 additions & 2 deletions src/commands/export-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ const BACKUP_AND_JOB_STATUS_QUERY = gql`
id
environments(id: $envId) {
id
backupsSqlDumpTool
latestBackup {
id
type
size
filename
sqlDumpTool
createdAt
}
jobs(jobTypes: [db_backup_copy]) {
Expand Down Expand Up @@ -98,6 +100,7 @@ async function fetchLatestBackupAndJobStatusBase(
): Promise< {
latestBackup: Backup | undefined;
jobs: Job[];
envSqlDumpTool: string | null | undefined;
} > {
const api = API();

Expand All @@ -108,11 +111,12 @@ async function fetchLatestBackupAndJobStatusBase(
} );

const environments = response.data.app?.environments;
const envSqlDumpTool = environments?.[ 0 ]?.backupsSqlDumpTool;

const latestBackup: Backup | undefined = environments?.[ 0 ]?.latestBackup as Backup;
const jobs: Job[] = ( environments?.[ 0 ]?.jobs || [] ) as Job[];

return { latestBackup, jobs };
return { latestBackup, jobs, envSqlDumpTool };
}

async function fetchLatestBackupAndJobStatus(
Expand Down Expand Up @@ -412,7 +416,10 @@ export class ExportSQLCommand {
await this.runBackupJob();
}

const { latestBackup } = await fetchLatestBackupAndJobStatus( this.app.id, this.env.id );
const { latestBackup, envSqlDumpTool } = await fetchLatestBackupAndJobStatus(
this.app.id,
this.env.id
);

if ( ! latestBackup ) {
await this.track( 'error', {
Expand All @@ -436,6 +443,18 @@ export class ExportSQLCommand {
);
}

const showMyDumperWarning = ( latestBackup.sqlDumpTool ?? envSqlDumpTool ) === 'mydumper';
if ( showMyDumperWarning ) {
console.warn(
chalk.yellow.bold( 'WARNING:' ),
chalk.yellow(
'This is a large or complex database. The backup file for this database is generated with MyDumper. ' +
'The file can only be loaded with MyLoader. ' +
'For more information: https://github.com/mydumper/mydumper'
)
);
}

if ( await this.getExportJob() ) {
console.log(
`Attaching to an existing export for the backup with timestamp ${ latestBackup.createdAt }`
Expand Down
1 change: 1 addition & 0 deletions src/graphqlTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ export type Backup = {
filename?: Maybe< Scalars[ 'String' ][ 'output' ] >;
id?: Maybe< Scalars[ 'Float' ][ 'output' ] >;
size?: Maybe< Scalars[ 'Float' ][ 'output' ] >;
sqlDumpTool?: Maybe< Scalars[ 'String' ][ 'output' ] >;
type?: Maybe< Scalars[ 'String' ][ 'output' ] >;
};

Expand Down