Closed the03ennis closed 1 day ago
Hi @the03ennis when you enable datastore on an existing database, you will run into these issues because those fields are non-nullable. So, the only way around it is to either clear the database or run a script that backfills the existing data with those fields with sensible values.
we do not do this automatically because of the risks of tampering with customer data.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
GraphQL API, DataStore
Amplify Version
v6
Amplify Categories
api
Backend
Amplify CLI
Environment information
Describe the bug
Upon enabling conflict resolution in an already-populated database, the DataStore client cannot connect to the databse because "_version" and "_lastChangedAt" are not populated. If you try to add those fields manually and default them to something, it gives you errors such as:
type CreateEventInput has already a field with name _version
while the datastore client gives errors such as:
`Cannot return null for non-nullable type: 'Int' (/syncEvents/items[23]/_version)
Expected behavior
Upon enabling conflict resolution, the fields for _version and _lastChangedAt should be autopopulated with version 1 and today's date/time.
Reproduction steps
Create a datatable, populate it, enable conflict resolution, attempt to connect a datastore client to it.