According to the AWS Amplify documentation:
amplify push
".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, e.g., 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.
Key-value and document data modelsThis enables DynamoDB to have a flexible schema, so each row can have any number of columns at any point in time. This allows you to easily adapt the tables as your business requirements change, without having to redefine the table schema as you would in relational databases.
Using the CLI, developers can automatically create tables representing the schema defined at the application level on DynamoDB. Although DynamoDB is Amplify DataStore's default database solution, developers can create AWS AppSync resolvers to use different purpose-built database offerings provided by AWS.
DynamoDB provides four operations for basic create, read, update, and delete (CRUD) functionality. All these operations are atomic.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With