这是indexloc提供的服务,不要输入任何密码
Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This release contains the [PDV refactor (#4111)](https://github.com/hasura/graph
- server: some mutations that cannot be performed will no longer be in the schema (for instance, `delete_by_pk` mutations won't be shown to users that do not have select permissions on all primary keys) (#4111)
- server: miscellaneous description changes (#4111)
- server: treat the absence of `backend_only` configuration and `backend_only: false` equally (closing #5059) (#4111)
- console: allow user to cascade Postgres dependencies when dropping Postgres objects (close #5109) (#5248)
- cli: add missing global flags for seeds command (#5565)
- docs: add docs page on networking with docker (close #4346) (#4811)

Expand Down
3 changes: 2 additions & 1 deletion console/src/components/Services/Common/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export const getErrorMessage = (
notificationMessage = error.code;
}
} else if ('internal' in error && 'error' in error.internal) {
notificationMessage = `${error.code} : ${error.internal.error.message}`;
notificationMessage = `${error.internal.error.message}.
${error.internal.error.description}`;
} else if ('custom' in error) {
notificationMessage = error.custom;
} else if ('code' in error && 'error' in error && 'path' in error) {
Expand Down
19 changes: 13 additions & 6 deletions console/src/components/Services/Data/DataActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,16 +659,20 @@ const makeMigrationCall = (
}
customOnSuccess(data, globals.consoleMode, currMigrationMode);
};
const retryMigration = (err = {}, errMsg = '') => {
const retryMigration = (err = {}, errMsg = '', isPgCascade = false) => {
const errorDetails = getErrorMessage('', err);
const errorDetailsLines = errorDetails.split('\n');

dispatch(
showNotification(
{
title: errMsg,
level: 'error',
message: (
<p>
{getErrorMessage('', err)}
<br />
{errorDetailsLines.map((m, i) => (
<div key={i}>{m}</div>
))}
<br />
Do you want to drop the dependent items as well?
</p>
Expand All @@ -680,7 +684,7 @@ const makeMigrationCall = (
makeMigrationCall(
dispatch,
getState,
cascadeUpQueries(upQueries), // cascaded new up queries
cascadeUpQueries(upQueries, isPgCascade), // cascaded new up queries
downQueries,
migrationName,
customOnSuccess,
Expand All @@ -689,6 +693,7 @@ const makeMigrationCall = (
successMsg,
errorMsg,
shouldSkipSchemaReload,
false,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beerose Could you please add this change for the very next update?
Related to #5436

true // prevent further retry
),
},
Expand All @@ -700,8 +705,10 @@ const makeMigrationCall = (

const onError = err => {
if (!isRetry) {
const dependecyError = getDependencyError(err);
if (dependecyError) return retryMigration(dependecyError, errorMsg);
const { dependencyError, pgDependencyError } = getDependencyError(err);
if (dependencyError) return retryMigration(dependencyError, errorMsg);
if (pgDependencyError)
return retryMigration(pgDependencyError, errorMsg, true);
}

dispatch(handleMigrationErrors(errorMsg, err));
Expand Down
43 changes: 33 additions & 10 deletions console/src/components/Services/Data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,13 +791,23 @@ WHERE
export const isColTypeString = colType =>
['text', 'varchar', 'char', 'bpchar', 'name'].includes(colType);

export const cascadeUpQueries = (upQueries = []) =>
const cascadePGSqlQuery = sql => {
if (sql[sql.length - 1] === ';')
return sql.substr(0, sql.length - 1) + ' CASCADE;';
// SQL might have a " at the end
else if (sql[sql.length - 2] === ';')
return sql.substr(0, sql.length - 2) + ' CASCADE;';
return sql + ' CASCADE;';
};

export const cascadeUpQueries = (upQueries = [], isPgCascade = false) =>
upQueries.map((i = {}) => {
if (i.type === 'run_sql' || i.type === 'untrack_table') {
return {
...i,
args: {
...i.args,
...(isPgCascade && { sql: cascadePGSqlQuery(i.args.sql) }),
cascade: true,
},
};
Expand All @@ -808,14 +818,27 @@ export const cascadeUpQueries = (upQueries = []) =>
export const getDependencyError = (err = {}) => {
if (err.code == ERROR_CODES.dependencyError.code) {
// direct dependency error
return err;
} else if (err.code == ERROR_CODES.dataApiError.code) {
// message is coming as error, further parssing willbe based on message key
const actualError = isJsonString(err.message)
? JSON.parse(err.message)
: {};
if (actualError.code == ERROR_CODES.dependencyError.code) {
return { ...actualError, message: actualError.error };
}
return { dependencyError: err };
}
if (err.code == ERROR_CODES.dataApiError.code) {
// with CLI mode, error is getting as a string with the key `message`
err = isJsonString(err.message) ? JSON.parse(err.message) : {};
}

if (err.code == ERROR_CODES.dependencyError.code)
return {
dependencyError: { ...err, message: err.error },
};
if (
err.code === ERROR_CODES.postgresError.code &&
err?.internal?.error?.status_code === '2BP01' // pg dependent error > https://www.postgresql.org/docs/current/errcodes-appendix.html
)
return {
pgDependencyError: {
...err,
message: `${err?.internal?.error?.message}:\n
${err?.internal?.error?.description || ''}`,
},
};
return {};
};