[RFC] Create a migration function for datasource to add migrationVersion field #6022
Labels
bug
Something isn't working
multiple datasource
multiple datasource project
RFC
Substantial changes or new features that require community input to garner consensus.
v2.13.0
Background
When create a datasource, it does not have migrationVersion causes the migration cannot be triggered.
Currently, the datasource does not have migration function.(reference) When creating the datasource, the migrationVersion will not be created and this variable will be marked as
undefined
.So with the below migration logic, the migration result will depend on
doc.migrationVersion
. If doc.migrationVersion is undefined, then it will always be considered to up to date and does not need to apply migration for these data.Potential Soluion
Design
For now, I will use approach 2 to create a dummy migration function for giving the datasource a migrationVersion. And we need to think about two design related questions:
Q1: which version will we use for the dummy migration function
A: I will use 2.4.0 as the migrationVersion since this is the version we introduced the datasource
Q2: how do we implement the migration function:
A:
migrateDataSource
. This is a dummy migration function that returns the document without any changes since we currently do not have any schema change.'2.4.0'
migration uses theflow
function from lodash to apply themigrateDataSource
function, indicating this migration should be applied when upgrading to version 2.4.0Test for the changes
GET API request:
Output is:
We can see there is no migrationVersion included in the output.
We can see the migrationVersion is successfully added.
The text was updated successfully, but these errors were encountered: