amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

feat: add imported tables to data

Open dpilch opened this issue 8 months ago • 1 comments

Problem

Gen 1 -> Gen 2 table migration.

Issue number, if available: N/A

Changes

Add new props:

  • importedAmplifyDynamoDBTableMap - mapping of model name to table name for imported tables.
  • importedModels - List of model names that should be treated as imported. This gives fault tolerance if the importedAmplifyDynamoDBTableMap is missing or modified. The deploy will fail if the importedModels list does not match models in importedAmplifyDynamoDBTableMap.

Usage:

const schema = `
  type Blog @model {
    title: String
    content: String
    authors: [String]
  }
  type ImportedModel @model {
    description: String
  }
`;
const dataFactory = defineData({
  schema,
  importedAmplifyDynamoDBTableMap: {
    ImportedModel: 'ImportedModel-1234-dev',
  },
  importedModels: ['ImportedModel'],
});

Corresponding docs PR, if applicable: N/A

Validation

  • Unit testing

Checklist

  • [x] If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
  • [x] If this PR requires a change to the Project Architecture README, I have included that update in this PR.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

dpilch avatar Jun 25 '24 14:06 dpilch