fix to create correct down migrations for permission (close #1366) (#1376)

This commit is contained in:
Aravind Shankar 2019-01-16 16:22:52 +05:30 committed by Shahidh K Muhammed
parent 500a9b2582
commit e375c61e4a
3 changed files with 18 additions and 8 deletions

View File

@ -99,6 +99,7 @@ const defaultModifyState = {
},
},
permissionsState: { ...defaultPermissionsState },
prevPermissionState: { ...defaultPermissionsState },
ongoingRequest: false,
lastError: null,
lastSuccess: null,

View File

@ -274,17 +274,21 @@ const modifyReducer = (tableName, schemas, modifyStateOrig, action) => {
};
case PERM_OPEN_EDIT:
const permState = getBasePermissionsState(
action.tableSchema,
action.role,
action.query,
action.insertPermColumnRestriction
);
return {
...modifyState,
permissionsState: {
...getBasePermissionsState(
action.tableSchema,
action.role,
action.query,
action.insertPermColumnRestriction
),
...permState,
tableSchemas: schemas,
},
prevPermissionState: {
...permState,
},
};
case PERM_ADD_TABLE_SCHEMAS:

View File

@ -549,6 +549,9 @@ const permChangePermissions = changeType => {
const permissionsState = {
...getState().tables.modify.permissionsState,
};
const prevPermissionsState = {
...getState().tables.modify.prevPermissionState,
};
const limitEnabled = permissionsState.limitEnabled;
const table = permissionsState.table;
@ -579,7 +582,7 @@ const permChangePermissions = changeType => {
args: {
table: { name: table, schema: currentSchema },
role: role,
permission: permissionsState[query],
permission: prevPermissionsState[query],
},
};
permissionsUpQueries.push(deleteQuery);
@ -614,7 +617,6 @@ const permChangePermissions = changeType => {
delete permissionsState[query].localSet;
}
//
const deleteQuery = {
type: 'drop_' + query + '_permission',
args: {
@ -627,6 +629,9 @@ const permChangePermissions = changeType => {
permissionsDownQueries.push(deleteQuery);
}
// Reverse order of down migration
permissionsDownQueries.reverse();
// Apply migration
const migrationName =
changeType +