<commit_before>class Migration extends Document.MinorMigration
  name: "Adding mediaType field"

  forward: (db, collectionName, currentSchema, newSchema, callback) =>
    db.collection collectionName, (error, collection) =>
      return callback error if error
      collection.update {_schema: currentSchema, mediaType: {$exists: false}}, {$set: {mediaType: 'pdf'}}, {multi: true}, (error, count) =>
        return callback error if error
        Meteor.bindEnvironment(=>
          Storage.rename 'pdf', 'publication'
          super db, collectionName, currentSchema, newSchema, callback
        , callback)()

  backward: (db, collectionName, currentSchema, oldSchema, callback) =>
    db.collection collectionName, (error, collection) =>
      return callback error if error
      collection.update {_schema: currentSchema}, {$unset: {mediaType: ''}}, {multi: true}, (error, count) =>
        return callback error if error
        Meteor.bindEnvironment(=>
          Storage.rename 'publication', 'pdf'
          super db, collectionName, currentSchema, newSchema, callback
        , callback)()

Publication.addMigration new Migration()<commit_msg>More fixing of migrations. Bind Meteor environment.<commit_after>class Migration extends Document.MinorMigration
  name: "Adding mediaType field"

  forward: (db, collectionName, currentSchema, newSchema, callback) =>
    db.collection collectionName, Meteor.bindEnvironment (error, collection) =>
      return callback error if error
      collection.update {_schema: currentSchema, mediaType: {$exists: false}}, {$set: {mediaType: 'pdf'}}, {multi: true}, Meteor.bindEnvironment (error, count) =>
        return callback error if error
        Meteor.bindEnvironment(=>
          Storage.rename 'pdf', 'publication' if Storage.exists 'pdf'
          super db, collectionName, currentSchema, newSchema, callback
        , callback)()
      , callback
    , callback

  backward: (db, collectionName, currentSchema, oldSchema, callback) =>
    db.collection collectionName, Meteor.bindEnvironment (error, collection) =>
      return callback error if error
      collection.update {_schema: currentSchema}, {$unset: {mediaType: ''}}, {multi: true}, Meteor.bindEnvironment (error, count) =>
        return callback error if error
        Meteor.bindEnvironment(=>
          Storage.rename 'publication', 'pdf' if Storage.exists 'publication'
          super db, collectionName, currentSchema, newSchema, callback
        , callback)()
      , callback
    , callback

Publication.addMigration new Migration()
{'fraction_non_alphanumeric': 0.1092896174863388, 'fraction_numerical': 0.0, 'mean_word_length': 3.7728119180633146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7315261', 'n_tokens_mistral': 658, 'n_tokens_neox': 649, 'n_words': 209}