/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
  const collection = app.findCollectionByNameOrId("pbc_2800040823")

  // add field — relevance_locked is set to true whenever an admin edits
  // learning_relevance via the UI; mergeKnowledgeGraph must never overwrite
  // learning_relevance on a locked topic during re-extraction.
  collection.fields.addAt(5, new Field({
    "hidden": false,
    "id": "bool_relevance_locked",
    "name": "relevance_locked",
    "presentable": false,
    "required": false,
    "system": false,
    "type": "bool"
  }))

  return app.save(collection)
}, (app) => {
  const collection = app.findCollectionByNameOrId("pbc_2800040823")
  collection.fields.removeById("bool_relevance_locked")
  return app.save(collection)
})
