/// <reference path="../pb_data/types.d.ts" />
migrate(
  app => {
    const col = app.findCollectionByNameOrId('scoring_judges');
    if (col.fields.fieldNames().includes('isAutojudge')) {
      return app.save(col);
    }
    col.fields.addAt(
      col.fields.length,
      new Field({
        hidden: false,
        id: 'bool1779500000',
        name: 'isAutojudge',
        presentable: false,
        required: false,
        system: false,
        type: 'bool'
      })
    );
    return app.save(col);
  },
  app => {
    const col = app.findCollectionByNameOrId('scoring_judges');
    if (col.fields.fieldNames().includes('isAutojudge')) {
      col.fields.removeByName('isAutojudge');
    }
    return app.save(col);
  }
);
