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

  // update collection data
  unmarshal({
    "name": "player_stats_per_tournament"
  }, collection)

  // remove field
  collection.fields.removeById("_clone_YqC8")

  // remove field
  collection.fields.removeById("_clone_jZTo")

  // add field
  collection.fields.addAt(4, new Field({
    "autogeneratePattern": "",
    "hidden": false,
    "id": "_clone_XGbN",
    "max": 0,
    "min": 0,
    "name": "team_name",
    "pattern": "",
    "presentable": false,
    "primaryKey": false,
    "required": true,
    "system": false,
    "type": "text"
  }))

  // add field
  collection.fields.addAt(6, new Field({
    "autogeneratePattern": "",
    "hidden": false,
    "id": "_clone_uud6",
    "max": 0,
    "min": 0,
    "name": "tournament_name",
    "pattern": "",
    "presentable": false,
    "primaryKey": false,
    "required": true,
    "system": false,
    "type": "text"
  }))

  return app.save(collection)
}, (app) => {
  const collection = app.findCollectionByNameOrId("pbc_135889471")

  // update collection data
  unmarshal({
    "name": "player_stats"
  }, collection)

  // add field
  collection.fields.addAt(4, new Field({
    "autogeneratePattern": "",
    "hidden": false,
    "id": "_clone_YqC8",
    "max": 0,
    "min": 0,
    "name": "team_name",
    "pattern": "",
    "presentable": false,
    "primaryKey": false,
    "required": true,
    "system": false,
    "type": "text"
  }))

  // add field
  collection.fields.addAt(6, new Field({
    "autogeneratePattern": "",
    "hidden": false,
    "id": "_clone_jZTo",
    "max": 0,
    "min": 0,
    "name": "tournament_name",
    "pattern": "",
    "presentable": false,
    "primaryKey": false,
    "required": true,
    "system": false,
    "type": "text"
  }))

  // remove field
  collection.fields.removeById("_clone_XGbN")

  // remove field
  collection.fields.removeById("_clone_uud6")

  return app.save(collection)
})
