简体   繁体   中英

DynamoDB schema updates with AWS Amplify

According to the AWS Amplify documentation:

It seems clear that amplify push creates a DynamoDB table for each @model.

My questions relate to schema updates:

  • I imagine that adding/removing a model or adding/removing a field in a model works by updating the schema document and then running amplify push . Is that right?

  • How does one rename a model or a field? How would amplify push know to rename vs. drop the old and add the new?

  • How does one implement a migration that requires some business logic, eg, to update the contents of existing rows? Doing this without Amplify has already been addressed but it is unclear whether that would conflict with something that amplify push might try to do.

DynamoDB is schema-less, and doesn't care about your application schema as long as you don't try to change its hash key or range key

Therefore, nothing really happens on the datastore side. If you drop a key and add a new one in your schema, then your application will start to search and write data to the new key. Old key will simply be ignored from now on, but existing data will be kept in the datastore.

If you want to rename a key, then you would have to migrate the data by yourself through mass update on the table. There are many ways to do it, the simpliest one being scaning the table and performing updates on found items.

你有没有试过用这个编译模式:

amplify api gql-compile

Have you tried

amplify codegen models

before doing the

amplify push

after?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM