Skip to content

Commit

Permalink
chore: default the data migration flag for createdbyuserid to false (#…
Browse files Browse the repository at this point in the history
…6048)

## About the changes

Sets data migration of features and events created_by_user_id to
disabled by default

Map to promise and await all in created by user id migration for features
  • Loading branch information
daveleek committed Jan 29, 2024
1 parent ce219f1 commit e652af4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -79,7 +79,7 @@ exports[`should create default config 1`] = `
"caseInsensitiveInOperators": false,
"celebrateUnleash": false,
"changeRequestConflictHandling": false,
"createdByUserIdDataMigration": true,
"createdByUserIdDataMigration": false,
"customRootRolesKillSwitch": false,
"demo": false,
"detectSegmentUsageInChangeRequests": false,
Expand Down
8 changes: 5 additions & 3 deletions src/lib/features/feature-toggle/feature-toggle-store.ts
Expand Up @@ -746,15 +746,17 @@ export default class FeatureToggleStore implements IFeatureToggleStore {
.limit(batchSize)
.select(['f.*', 'ev.created_by', 'u.id', 't.username']);

toUpdate
const updatePromises = toUpdate
.filter((row) => row.id || row.username)
.forEach(async (row) => {
.map((row) => {
const id = row.id || ADMIN_TOKEN_USER.id;

await this.db(TABLE)
return this.db(TABLE)
.update({ created_by_user_id: id })
.where({ name: row.name });
});

await Promise.all(updatePromises);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/types/experimental.ts
Expand Up @@ -225,7 +225,7 @@ const flags: IFlags = {
},
createdByUserIdDataMigration: parseEnvVarBoolean(
process.env.CREATED_BY_USERID_DATA_MIGRATION,
true,
false,
),
};

Expand Down
1 change: 1 addition & 0 deletions src/test/config/test-config.ts
Expand Up @@ -27,6 +27,7 @@ export function createTestConfig(config?: IUnleashOptions): IUnleashConfig {
flags: {
embedProxy: true,
embedProxyFrontend: true,
createdByUserIdDataMigration: true,
},
},
publicFolder: path.join(__dirname, '../examples'),
Expand Down

0 comments on commit e652af4

Please sign in to comment.