batch / bulk update pre-existing items or add new items to a data model
Environment information
System:
OS: macOS 14.0
CPU: (10) arm64 Apple M1 Pro
Memory: 180.89 MB / 32.00 GB
Shell: /bin/zsh
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v18.16.0/bin/yarn
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
pnpm: undefined - undefined
NPM Packages:
@aws-amplify/backend: 1.0.2
@aws-amplify/backend-cli: 1.0.3
aws-amplify: 6.3.4
aws-cdk: 2.143.1
aws-cdk-lib: 2.143.1
typescript: 5.4.5
AWS environment variables:
AWS_STS_REGIONAL_ENDPOINTS = regional
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables
Description
I have setup a data backend running in production and I am now updating a modal, say:
User: a
.model({
id: a.id().required(),
name: a.string(),
})
.authorization((allow) => [allow.owner()]),
I wish to add a new field to that model, say isVerifed which will be a boolean. For all current users this field will not exist and I will need to update those users to be true. How is it best to make this change? Will amplify-backend provide utils for this such cases to ensure that the data meets the scheme shape I already have. There are obviously a few ways one could try script this or attempt to handle migrations but none feel robust.
Is amplify developing an API for this or what are the best practises in handling these changes?
Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂
Hey @TamsynJennifer4, Thank you for bringing this to our attention. Unfortunately, there is no built-in feature for performing bulk updates in this case. After adding the property to the schema, you can update the field by writing a one-time Lambda function to retrieve the list of users and update them in a loop.
Thanks for the information. Is this a road-map feature for the API? I'm sure there are hundreds of teams running migrations on a daily basis and a simple API to handle this would greatly benefit the community.
Agree with @TamsynJennifer4 , is there any ETA or update if this is going to be implemented