Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen1 migration #3084

Merged
merged 14 commits into from
Feb 14, 2025
Merged

Gen1 migration #3084

merged 14 commits into from
Feb 14, 2025

Conversation

dpilch
Copy link
Member

@dpilch dpilch commented Dec 18, 2024

Description of changes

  • Add transformer option enableGen2Migration.
    • Set dynamodb table data source removal policy to retain when true.
    • Output a mapping of model name to table name when true.
    • This will be exposed as a feature flag to gen 1 customers.
CDK / CloudFormation Parameters Changed

New behavior is not exposed through the construct because migration is not supported from construct to gen 2.

Issue #, if available

N/A

Description of how you validated changes

  • Add transformer option enableGen2Migration.
    • Set dynamodb table data source removal policy to retain when true.
    • Output a mapping of model name to table name when true.

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Any CDK or CloudFormation parameter changes are called out explicitly

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

@dpilch dpilch changed the base branch from main to release-api-plugin-stable December 18, 2024 18:36
@dpilch dpilch mentioned this pull request Dec 18, 2024
4 tasks
@dpilch dpilch marked this pull request as ready for review February 12, 2025 16:58
@dpilch dpilch requested review from a team as code owners February 12, 2025 16:58
Comment on lines 334 to 340
if (datasource.ds.dynamoDbConfig && !cdk.isResolvableObject(datasource.ds.dynamoDbConfig)) {
dataSourceMapping[modelName] = datasource.ds.dynamoDbConfig.tableName;
} else {
console.warn(
`Could not resolve table name for ${modelName}. DataSourceMappingOutput is incomplete. Please manually add ${modelName} to the mapping for your migration.`,
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Does this block mean that manually overridden table names aren't properly handled? In what cases would the warning be triggered? Is a warning sufficient? It's super easy to miss warnings in the output of a gen1 flow. Can we allow the customer to specify a manual configuration for the errored configs, and only throw an error if that manual specification isn't present?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was to make TypeScript happy. I haven't found a case where the else would actually execute.

Property 'tableName' does not exist on type 'DynamoDBConfigProperty | IResolvable'.
  Property 'tableName' does not exist on type 'IResolvable'.

Copy link
Contributor

Choose a reason for hiding this comment

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

How do we handle the cases where table name is changed using override api?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will correctly get the table name when using overrides. I just tested again to be sure.

type Todo @model {
  id: ID!
  name: String!
  description: String
}

Deploy without override adds the correct mapping with the generated table name.

Then I added this override.

// set custom table name
resources.models.Todo.modelDDBTable.addPropertyOverride(
  "TableName",
  "MyCustomTableName"
);

The table mapping output: {"Todo":"MyCustomTableName"}

});
if (context.transformParameters.enableGen2Migration && context.transformParameters.enableTransformerCfnOutputs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check transformer version in all these places? I think we need a way to stop V1 customers running this command.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, I've added a check in transformGraphQLSchemaV1 to prevent this.

@@ -103,7 +103,7 @@
"coverageProvider": "v8",
"coverageThreshold": {
"global": {
"branches": 67,
"branches": 66,
Copy link
Member Author

Choose a reason for hiding this comment

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

Coverage decreased slightly because of the unreachable error message.

@dpilch dpilch merged commit 7263b2c into release-api-plugin-stable Feb 14, 2025
10 checks passed
@dpilch dpilch deleted the gen1-migration branch February 14, 2025 20:49
bobbyu99 added a commit that referenced this pull request Feb 20, 2025
bobbyu99 added a commit that referenced this pull request Feb 20, 2025
* Revert "feat: add enableGen2Migration feature flag (#3084)"

This reverts commit 7263b2c.

* refresh yarn.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants