Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 1 addition & 27 deletions app/lib/tool/backfill/backfill_new_fields.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:logging/logging.dart';
import 'package:pub_dev/account/models.dart';
import 'package:pub_dev/package/models.dart';
import 'package:pub_dev/publisher/models.dart';
import 'package:pub_dev/shared/datastore.dart';

final _logger = Logger('backfill_new_fields');

Expand All @@ -16,27 +12,5 @@ final _logger = Logger('backfill_new_fields');
/// CHANGELOG.md must be updated with the new fields, and the next
/// release could remove the backfill from here.
Future<void> backfillNewFields() async {
await _removeKnownUnmappedFields();
}

Future<void> _removeKnownUnmappedFields() async {
_logger.info('Removing unmapped fields...');

Future<void> removeIsBlocked<T extends ExpandoModel>() async {
await for (final p in dbService.query<T>().run()) {
if (p.additionalProperties.isEmpty) continue;
if (p.additionalProperties.containsKey('isBlocked')) {
await withRetryTransaction(dbService, (tx) async {
final e = await tx.lookupValue<T>(p.key);
e.additionalProperties.remove('isBlocked');
tx.insert(e);
});
}
}
}

await removeIsBlocked<Package>();
await removeIsBlocked<Publisher>();
await removeIsBlocked<User>();
_logger.info('Removing unmapped fields completed.');
_logger.info('No new fields.');
}