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 (#8144)" (#8268)

This reverts commit 2d4e65a.
  • Loading branch information
sundersc authored and cjihrig-aws committed Sep 27, 2021
1 parent 17aa0a2 commit bb67a35
Show file tree
Hide file tree
Showing 32 changed files with 205 additions and 1,269 deletions.
46 changes: 8 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1307,22 +1307,14 @@ jobs:
environment:
TEST_SUITE: src/__tests__/auth_6.test.ts
CLI_REGION: eu-central-1
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: ap-northeast-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-southeast-1
CLI_REGION: ap-northeast-1
schema-iterative-update-4-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
Expand Down Expand Up @@ -2133,16 +2125,6 @@ jobs:
TEST_SUITE: src/__tests__/auth_6.test.ts
CLI_REGION: eu-central-1
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: ap-northeast-1
steps: *ref_6
api_4-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
Expand All @@ -2151,7 +2133,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-southeast-1
CLI_REGION: ap-northeast-1
steps: *ref_6
workflows:
version: 2
Expand Down Expand Up @@ -2274,11 +2256,11 @@ workflows:
- tags-amplify_e2e_tests
- sandbox-mode-amplify_e2e_tests
- function_7-amplify_e2e_tests
- api_5-amplify_e2e_tests
- api_4-amplify_e2e_tests
- amplify-app-amplify_e2e_tests
- init-amplify_e2e_tests
- s3-sse-amplify_e2e_tests
- function_6-amplify_e2e_tests
- api_4-amplify_e2e_tests
- schema-predictions-amplify_e2e_tests
- amplify-configure-amplify_e2e_tests
- pull-amplify_e2e_tests
Expand All @@ -2304,11 +2286,11 @@ workflows:
- tags-amplify_e2e_tests_pkg_linux
- sandbox-mode-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
- amplify-app-amplify_e2e_tests_pkg_linux
- init-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
- schema-predictions-amplify_e2e_tests_pkg_linux
- amplify-configure-amplify_e2e_tests_pkg_linux
- pull-amplify_e2e_tests_pkg_linux
Expand Down Expand Up @@ -2816,7 +2798,7 @@ workflows:
filters: *ref_10
requires:
- geo-update-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 @@ -2894,12 +2876,6 @@ workflows:
filters: *ref_10
requires:
- hostingPROD-amplify_e2e_tests
- api_4-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
filters: *ref_10
requires:
- amplify-app-amplify_e2e_tests
- schema-iterative-update-3-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
Expand Down Expand Up @@ -3344,7 +3320,7 @@ workflows:
filters: *ref_13
requires:
- geo-update-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 @@ -3426,12 +3402,6 @@ workflows:
filters: *ref_13
requires:
- hostingPROD-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
filters: *ref_13
requires:
- amplify-app-amplify_e2e_tests_pkg_linux
- schema-iterative-update-3-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-category-api/amplify-plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "api",
"type": "category",
"commands": ["add-graphql-datasource", "add", "console", "gql-compile", "push", "rebuild", "remove", "update", "help"],
"commands": ["add-graphql-datasource", "add", "console", "gql-compile", "push", "remove", "update", "help"],
"commandAliases": {
"configure": "update"
},
Expand Down
2 changes: 0 additions & 2 deletions packages/amplify-category-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +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-provider-awscloudformation": "4.60.1",
"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
Loading

0 comments on commit bb67a35

Please sign in to comment.