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

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

  // update field
  collection.fields.addAt(5, new Field({
    "autogeneratePattern": "",
    "hidden": false,
    "id": "text1569282101",
    "max": 0,
    "min": 0,
    "name": "order_id",
    "pattern": "",
    "presentable": false,
    "primaryKey": false,
    "required": false,
    "system": false,
    "type": "text"
  }))

  // update field
  collection.fields.addAt(6, new Field({
    "hidden": false,
    "id": "select2063623452",
    "maxSelect": 1,
    "name": "order_status",
    "presentable": false,
    "required": true,
    "system": false,
    "type": "select",
    "values": [
      "created",
      "processing",
      "completed",
      "rejected",
      "refund_requested",
      "refunded",
      "refunded_partially",
      "auth_requested",
      "blocked",
      "partial_completed"
    ]
  }))

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

  // add field
  collection.fields.addAt(11, new Field({
    "cascadeDelete": false,
    "collectionId": "pbc_3980638064",
    "hidden": false,
    "id": "relation2747688147",
    "maxSelect": 1,
    "minSelect": 0,
    "name": "subscription",
    "presentable": false,
    "required": false,
    "system": false,
    "type": "relation"
  }))

  // update field
  collection.fields.addAt(5, new Field({
    "autogeneratePattern": "",
    "hidden": false,
    "id": "text1569282101",
    "max": 0,
    "min": 0,
    "name": "gateway_transaction_id",
    "pattern": "",
    "presentable": false,
    "primaryKey": false,
    "required": false,
    "system": false,
    "type": "text"
  }))

  // update field
  collection.fields.addAt(6, new Field({
    "hidden": false,
    "id": "select2063623452",
    "maxSelect": 1,
    "name": "status",
    "presentable": false,
    "required": true,
    "system": false,
    "type": "select",
    "values": [
      "failed",
      "pending",
      "completed",
      "cancelled",
      "disputed"
    ]
  }))

  return app.save(collection)
})
