aws-amplify / amplify-swift

A declarative library for application development using cloud services.
Apache License 2.0
436 stars 192 forks source link

All production users local data gets lost on DataStore migration #3746

Open amruth-movano opened 3 weeks ago

amruth-movano commented 3 weeks ago

Describe the bug

Hi Team, almost all production users data got lost when updated AmplifyModels. Before updating the app, users were having all the data, once they updated the app, their old local data got lost. Its heartbreaking.....🥲🥲🥲 as our app is health app and all the health data is lost now.

Steps To Reproduce

-

Expected behavior

Datastore should not clear the local data

Amplify Framework Version

2.33.6

Amplify Categories

DataStore

Dependency manager

Swift PM

Swift version

5.9.2

CLI version

12.11.1

Xcode version

15.0

Relevant log output

-

Is this a regression?

Yes

Regression additional context

No response

Platforms

iOS

OS Version

iOS 17.0

Device

iPhone15

Specific to simulators

No response

Additional context

No response

amruth-movano commented 3 weeks ago

@lawmicha @5d Can you see this please on high priority?

amruth-movano commented 3 weeks ago

Only one table model, schema got updated but datastore erased all local data including other table local data also. @lawmicha @5d

thisisabhash commented 3 weeks ago

Thank you for posting the issue.

Local migrations (i.e. migrations controlled by the developer) on device are not currently supported. Therefore, your local data will be lost when the schema changes. If you are syncing with the cloud the structure and items of that data in your AppSync backend will not be touched as part of this process. https://docs.amplify.aws/gen1/swift/build-a-backend/more-features/datastore/schema-updates/#local-migrations

github-actions[bot] commented 3 weeks ago

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

amruth-movano commented 3 weeks ago

@thisisabhash We have modified one table schema only. But data store cleared all other tables also. Can you please explain why this is happening?

thisisabhash commented 3 weeks ago

The reason for clearing the entire local database is because we don't know the details of the schema changes, if it was an additive or destructive change. So, Amplify assumes it can no longer operate on the same tables.

The local database contains the tables from before the schema changes and also, some internal tables to perform Datastore's sync engine related tasks. This is a feature request - to perform more granular operations during schema upgrades which will facilitate local migration.