Skip to content

Commit

Permalink
Revert "feat: Flag to allow schema changes that require table replace…
Browse files Browse the repository at this point in the history
…ment (aws-amplify#8144)" (aws-amplify#8268)

This reverts commit 2d4e65a.
  • Loading branch information
sundersc authored and marcvberg committed Oct 13, 2021
1 parent 576887d commit 040f1ba
Show file tree
Hide file tree
Showing 32 changed files with 233 additions and 1,298 deletions.
46 changes: 8 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1299,22 +1299,14 @@ jobs:
environment:
TEST_SUITE: src/__tests__/auth_6.test.ts
CLI_REGION: eu-west-2
api_5-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_5
environment:
TEST_SUITE: src/__tests__/api_5.test.ts
CLI_REGION: eu-central-1
api_4-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_5
environment:
TEST_SUITE: src/__tests__/api_4.test.ts
CLI_REGION: ap-northeast-1
CLI_REGION: eu-central-1
schema-iterative-update-4-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
Expand Down Expand Up @@ -2115,16 +2107,6 @@ jobs:
TEST_SUITE: src/__tests__/auth_6.test.ts
CLI_REGION: eu-west-2
steps: *ref_6
api_5-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
resource_class: large
environment:
AMPLIFY_DIR: /home/circleci/repo/out
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux
TEST_SUITE: src/__tests__/api_5.test.ts
CLI_REGION: eu-central-1
steps: *ref_6
api_4-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
Expand All @@ -2133,7 +2115,7 @@ jobs:
AMPLIFY_DIR: /home/circleci/repo/out
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux
TEST_SUITE: src/__tests__/api_4.test.ts
CLI_REGION: ap-northeast-1
CLI_REGION: eu-central-1
steps: *ref_6
workflows:
version: 2
Expand Down Expand Up @@ -2252,11 +2234,11 @@ workflows:
- notifications-amplify_e2e_tests
- schema-iterative-update-locking-amplify_e2e_tests
- function_7-amplify_e2e_tests
- api_5-amplify_e2e_tests
- api_4-amplify_e2e_tests
- hosting-amplify_e2e_tests
- tags-amplify_e2e_tests
- s3-sse-amplify_e2e_tests
- function_6-amplify_e2e_tests
- api_4-amplify_e2e_tests
- amplify-app-amplify_e2e_tests
- init-amplify_e2e_tests
- pull-amplify_e2e_tests
Expand All @@ -2282,11 +2264,11 @@ workflows:
- notifications-amplify_e2e_tests_pkg_linux
- schema-iterative-update-locking-amplify_e2e_tests_pkg_linux
- function_7-amplify_e2e_tests_pkg_linux
- api_5-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux
- hosting-amplify_e2e_tests_pkg_linux
- tags-amplify_e2e_tests_pkg_linux
- s3-sse-amplify_e2e_tests_pkg_linux
- function_6-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux
- amplify-app-amplify_e2e_tests_pkg_linux
- init-amplify_e2e_tests_pkg_linux
- pull-amplify_e2e_tests_pkg_linux
Expand Down Expand Up @@ -2726,7 +2708,7 @@ workflows:
filters: *ref_10
requires:
- geo-remove-amplify_e2e_tests
- api_5-amplify_e2e_tests:
- api_4-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
filters: *ref_10
Expand Down Expand Up @@ -2798,12 +2780,6 @@ workflows:
filters: *ref_10
requires:
- geo-update-amplify_e2e_tests
- api_4-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
filters: *ref_10
requires:
- hosting-amplify_e2e_tests
- schema-auth-2-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
Expand Down Expand Up @@ -3244,7 +3220,7 @@ workflows:
filters: *ref_13
requires:
- geo-remove-amplify_e2e_tests_pkg_linux
- api_5-amplify_e2e_tests_pkg_linux:
- api_4-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
filters: *ref_13
Expand Down Expand Up @@ -3320,12 +3296,6 @@ workflows:
filters: *ref_13
requires:
- geo-update-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
filters: *ref_13
requires:
- hosting-amplify_e2e_tests_pkg_linux
- schema-auth-2-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
Expand Down
25 changes: 17 additions & 8 deletions packages/amplify-category-api/amplify-plugin.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{
"name": "api",
"type": "category",
"commands": ["add-graphql-datasource", "add", "console", "gql-compile", "push", "rebuild", "remove", "update", "help"],
"commandAliases": {
"configure": "update"
},
"eventHandlers": []
}
"name": "api",
"type": "category",
"commands": [
"add-graphql-datasource",
"add",
"console",
"gql-compile",
"push",
"remove",
"update",
"help"
],
"commandAliases":{
"configure": "update"
},
"eventHandlers": []
}
1 change: 0 additions & 1 deletion packages/amplify-category-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"@octokit/rest": "^18.0.9",
"amplify-cli-core": "1.29.0",
"amplify-headless-interface": "1.10.0",
"amplify-prompts": "1.1.2",
"amplify-util-headless-input": "1.5.4",
"chalk": "^4.1.1",
"constructs": "^3.3.125",
Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions packages/amplify-category-api/src/commands/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ module.exports = {
name: 'console',
description: 'Opens the web console for the selected api service',
},
{
name: 'rebuild',
description:
'Removes and recreates all DynamoDB tables backing a GraphQL API. Useful for resetting test data during the development phase of an app',
},
];

context.amplify.showHelp(header, commands);
Expand Down
40 changes: 0 additions & 40 deletions packages/amplify-category-api/src/commands/api/rebuild.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/amplify-category-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"src/__tests__"
],
"references": [
{"path": "../amplify-cli-core"},
{"path": "../amplify-headless-interface"},
{"path": "../amplify-prompts"},
{"path": "../graphql-transformer-core"},
{"path": "../amplify-util-headless-input"},
]
Expand Down
1 change: 0 additions & 1 deletion packages/amplify-category-function/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export { hashLayerResource } from './provider-utils/awscloudformation/utils/laye
export { migrateLegacyLayer } from './provider-utils/awscloudformation/utils/layerMigrationUtils';
export { packageResource } from './provider-utils/awscloudformation/utils/package';
export { updateDependentFunctionsCfn } from './provider-utils/awscloudformation/utils/updateDependentFunctionCfn';
export { loadFunctionParameters } from './provider-utils/awscloudformation/utils/loadFunctionParameters';

export async function add(context, providerName, service, parameters) {
const options = {
Expand Down
1 change: 0 additions & 1 deletion packages/amplify-cli-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ interface AmplifyToolkit {
category?: string,
resourceName?: string,
filteredResources?: { category: string; resourceName: string }[],
rebuild?: boolean,
) => $TSAny;
storeCurrentCloudBackend: () => $TSAny;
readJsonFile: (fileName: string) => $TSAny;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export async function pushResources(
category?: string,
resourceName?: string,
filteredResources?: { category: string; resourceName: string }[],
rebuild: boolean = false,
) {
if (context.parameters.options['iterative-rollback']) {
// validate --iterative-rollback with --force
Expand Down Expand Up @@ -50,21 +49,16 @@ export async function pushResources(
}
}

let hasChanges = false;
if (!rebuild) {
// status table does not have a way to show resource in "rebuild" state so skipping it to avoid confusion
hasChanges = await showResourceTable(category, resourceName, filteredResources);
}
const hasChanges = await showResourceTable(category, resourceName, filteredResources);

// no changes detected
if (!hasChanges && !context.exeInfo.forcePush && !rebuild) {
if (!hasChanges && !context.exeInfo.forcePush) {
context.print.info('\nNo changes detected');

return context;
}

// rebuild has an upstream confirmation prompt so no need to prompt again here
let continueToPush = (context.exeInfo && context.exeInfo.inputParams && context.exeInfo.inputParams.yes) || rebuild;
let continueToPush = context.exeInfo && context.exeInfo.inputParams && context.exeInfo.inputParams.yes;

if (!continueToPush) {
if (context.exeInfo.iterativeRollback) {
Expand All @@ -74,11 +68,18 @@ export async function pushResources(
}

if (continueToPush) {
// Get current-cloud-backend's amplify-meta
const currentAmplifyMeta = stateManager.getCurrentMeta();
try {
// Get current-cloud-backend's amplify-meta
const currentAmplifyMeta = stateManager.getCurrentMeta();

await providersPush(context, category, resourceName, filteredResources);
await onCategoryOutputsChange(context, currentAmplifyMeta);
} catch (err) {
// Handle the errors and print them nicely for the user.
context.print.error(`\n${err.message}`);

await providersPush(context, rebuild, category, resourceName, filteredResources);
await onCategoryOutputsChange(context, currentAmplifyMeta);
throw err;
}
} else {
// there's currently no other mechanism to stop the execution of the postPush workflow in this case, so exiting here
exitOnNextTick(1);
Expand All @@ -87,21 +88,15 @@ export async function pushResources(
return continueToPush;
}

async function providersPush(
context: $TSContext,
rebuild: boolean = false,
category?: string,
resourceName?: string,
filteredResources?: { category: string; resourceName: string }[],
) {
async function providersPush(context: $TSContext, category, resourceName, filteredResources) {
const { providers } = getProjectConfig();
const providerPlugins = getProviderPlugins(context);
const providerPromises: (() => Promise<$TSAny>)[] = [];

for (const provider of providers) {
const providerModule = require(providerPlugins[provider]);
const resourceDefiniton = await context.amplify.getResourceStatus(category, resourceName, provider, filteredResources);
providerPromises.push(providerModule.pushResources(context, resourceDefiniton, rebuild));
providerPromises.push(providerModule.pushResources(context, resourceDefiniton));
}

await Promise.all(providerPromises);
Expand Down
10 changes: 0 additions & 10 deletions packages/amplify-e2e-core/src/categories/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,3 @@ export function addRestContainerApi(projectDir: string) {
});
});
}

export function rebuildApi(projDir: string, apiName: string) {
return new Promise<void>((resolve, reject) => {
spawn(getCLIPath(), ['rebuild', 'api'], { cwd: projDir, stripColors: true })
.wait('Type the name of the API to confirm you want to continue')
.sendLine(apiName)
.wait('All resources are updated in the cloud')
.run(err => (err ? reject(err) : resolve()));
});
}
Loading

0 comments on commit 040f1ba

Please sign in to comment.