/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
  const dao = new Dao(db)
  const collection = dao.findCollectionByNameOrId("1ixwljuo2xqxcqj")

  // remove
  collection.schema.removeField("kkjhfk5h")

  // remove
  collection.schema.removeField("ygnod47v")

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "wo6r0pay",
    "name": "theme",
    "type": "relation",
    "required": true,
    "presentable": false,
    "unique": false,
    "options": {
      "collectionId": "bm117d8jhn68xqr",
      "cascadeDelete": false,
      "minSelect": null,
      "maxSelect": 1,
      "displayFields": null
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "8bnzwbwk",
    "name": "title",
    "type": "text",
    "required": true,
    "presentable": false,
    "unique": false,
    "options": {
      "min": null,
      "max": null,
      "pattern": ""
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "lwhabbnq",
    "name": "body",
    "type": "editor",
    "required": false,
    "presentable": false,
    "unique": false,
    "options": {
      "convertUrls": false
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "8tjttsyu",
    "name": "difficulty",
    "type": "select",
    "required": true,
    "presentable": false,
    "unique": false,
    "options": {
      "maxSelect": 1,
      "values": [
        "introductory",
        "intermediate",
        "advanced"
      ]
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "qngdg6m0",
    "name": "complexity_weight",
    "type": "number",
    "required": false,
    "presentable": false,
    "unique": false,
    "options": {
      "min": null,
      "max": null,
      "noDecimal": false
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "dccnzcbc",
    "name": "status",
    "type": "select",
    "required": true,
    "presentable": false,
    "unique": false,
    "options": {
      "maxSelect": 1,
      "values": [
        "draft",
        "published"
      ]
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "3rkaaglp",
    "name": "key_terms",
    "type": "json",
    "required": false,
    "presentable": false,
    "unique": false,
    "options": {
      "maxSize": 2097152
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "byhuuhif",
    "name": "qdrant_chunk_ids",
    "type": "json",
    "required": false,
    "presentable": false,
    "unique": false,
    "options": {
      "maxSize": 2097152
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "8h7ygavu",
    "name": "related_topics",
    "type": "relation",
    "required": false,
    "presentable": false,
    "unique": false,
    "options": {
      "collectionId": "1ixwljuo2xqxcqj",
      "cascadeDelete": false,
      "minSelect": null,
      "maxSelect": null,
      "displayFields": null
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "dwhl1pqg",
    "name": "prerequisite_topics",
    "type": "relation",
    "required": false,
    "presentable": false,
    "unique": false,
    "options": {
      "collectionId": "1ixwljuo2xqxcqj",
      "cascadeDelete": false,
      "minSelect": null,
      "maxSelect": null,
      "displayFields": null
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "38phv8cm",
    "name": "contrast_topics",
    "type": "relation",
    "required": false,
    "presentable": false,
    "unique": false,
    "options": {
      "collectionId": "1ixwljuo2xqxcqj",
      "cascadeDelete": false,
      "minSelect": null,
      "maxSelect": null,
      "displayFields": null
    }
  }))

  return dao.saveCollection(collection)
}, (db) => {
  const dao = new Dao(db)
  const collection = dao.findCollectionByNameOrId("1ixwljuo2xqxcqj")

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "kkjhfk5h",
    "name": "theme",
    "type": "relation",
    "required": true,
    "presentable": false,
    "unique": false,
    "options": {
      "collectionId": "bm117d8jhn68xqr",
      "cascadeDelete": false,
      "minSelect": null,
      "maxSelect": 1,
      "displayFields": null
    }
  }))

  // add
  collection.schema.addField(new SchemaField({
    "system": false,
    "id": "ygnod47v",
    "name": "body",
    "type": "editor",
    "required": false,
    "presentable": false,
    "unique": false,
    "options": {
      "convertUrls": false
    }
  }))

  // remove
  collection.schema.removeField("wo6r0pay")

  // remove
  collection.schema.removeField("8bnzwbwk")

  // remove
  collection.schema.removeField("lwhabbnq")

  // remove
  collection.schema.removeField("8tjttsyu")

  // remove
  collection.schema.removeField("qngdg6m0")

  // remove
  collection.schema.removeField("dccnzcbc")

  // remove
  collection.schema.removeField("3rkaaglp")

  // remove
  collection.schema.removeField("byhuuhif")

  // remove
  collection.schema.removeField("8h7ygavu")

  // remove
  collection.schema.removeField("dwhl1pqg")

  // remove
  collection.schema.removeField("38phv8cm")

  return dao.saveCollection(collection)
})
