33// BSD-style license that can be found in the LICENSE file.
44
55import 'package:logging/logging.dart' ;
6+ import 'package:pub_dev/account/models.dart' ;
67import 'package:pub_dev/package/models.dart' ;
8+ import 'package:pub_dev/publisher/models.dart' ;
79import 'package:pub_dev/shared/datastore.dart' ;
810
911final _logger = Logger ('backfill_new_fields' );
@@ -19,19 +21,22 @@ Future<void> backfillNewFields() async {
1921
2022Future <void > _removeKnownUnmappedFields () async {
2123 _logger.info ('Removing unmapped fields...' );
22- await for (final p in dbService.query <Package >().run ()) {
23- if (p.additionalProperties.isEmpty) continue ;
24- if (p.additionalProperties.containsKey ('automatedPublishingJson' ) ||
25- p.additionalProperties.containsKey ('blocked' ) ||
26- p.additionalProperties.containsKey ('blockedReason' )) {
27- await withRetryTransaction (dbService, (tx) async {
28- final pkg = await tx.lookupValue <Package >(p.key);
29- pkg.additionalProperties.remove ('automatedPublishingJson' );
30- pkg.additionalProperties.remove ('blocked' );
31- pkg.additionalProperties.remove ('blockedReason' );
32- tx.insert (pkg);
33- });
24+
25+ Future <void > removeIsBlocked <T extends ExpandoModel >() async {
26+ await for (final p in dbService.query <T >().run ()) {
27+ if (p.additionalProperties.isEmpty) continue ;
28+ if (p.additionalProperties.containsKey ('isBlocked' )) {
29+ await withRetryTransaction (dbService, (tx) async {
30+ final e = await tx.lookupValue <T >(p.key);
31+ e.additionalProperties.remove ('isBlocked' );
32+ tx.insert (e);
33+ });
34+ }
3435 }
3536 }
37+
38+ await removeIsBlocked <Package >();
39+ await removeIsBlocked <Publisher >();
40+ await removeIsBlocked <User >();
3641 _logger.info ('Removing unmapped fields completed.' );
3742}
0 commit comments