var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var update_target_exports = {};
__export(update_target_exports, {
  default: () => update_target_default
});
module.exports = __toCommonJS(update_target_exports);
var import_server = require("@tego/server");
class update_target_default extends import_server.Migration {
  constructor() {
    super(...arguments);
    this.on = "afterLoad";
    // 'beforeLoad' or 'afterLoad'
    this.appVersion = "<0.20.0-alpha.6";
  }
  async up() {
    const r = this.db.getRepository("fields");
    const fields = await r.find({
      filter: {
        interface: "attachment"
      }
    });
    for (const field of fields) {
      const options = field.get("options");
      if (options.target !== "attachments") {
        options.target = "attachments";
        field.set("options", options);
        field.changed("options", true);
        await field.save();
      }
    }
  }
}
