Fix committing metadata value migrations
In case the "oldValue" was a regex expression, the values never matched, which caused the value migration to never get committed.
This commit is contained in:
@@ -240,8 +240,11 @@ const getMetadataKeysWithUpdatedValues = (
|
|||||||
const keysWithUpdatedValues = METADATA_MIGRATIONS.slice(migrationId).reduce((acc, migration) => {
|
const keysWithUpdatedValues = METADATA_MIGRATIONS.slice(migrationId).reduce((acc, migration) => {
|
||||||
const keysWithUpdatedValuesOfMigration = Object.keys(metadata).filter((metadataKey) =>
|
const keysWithUpdatedValuesOfMigration = Object.keys(metadata).filter((metadataKey) =>
|
||||||
migration.values?.some(({ key: migrationKey, oldValue }) => {
|
migration.values?.some(({ key: migrationKey, oldValue }) => {
|
||||||
|
const currentValue = metadata[metadataKey];
|
||||||
|
|
||||||
const isMigrationForAllKeys = !migrationKey;
|
const isMigrationForAllKeys = !migrationKey;
|
||||||
const doesValueMatch = metadata[metadataKey] === oldValue;
|
const doesValueMatch =
|
||||||
|
oldValue instanceof RegExp ? currentValue.match(oldValue) : currentValue === oldValue;
|
||||||
|
|
||||||
if (isMigrationForAllKeys) {
|
if (isMigrationForAllKeys) {
|
||||||
return doesValueMatch;
|
return doesValueMatch;
|
||||||
|
|||||||
Reference in New Issue
Block a user