// pb_migrations/0000000001_create_superuser.js

migrate(
  (app) => {
    const superusers_collection = app.findCollectionByNameOrId("_superusers");

    const record = new Record(superusers_collection);
    record.set("email", "admin@123.com");
    record.set("password", "Aa12345678");
    app.save(record);

    console.log("Superuser admin@123.com created via migration");
  },
  (app) => {
    try {
      const record = app.findAuthRecordByEmail(
        "_superusers",
        "admin@example.com"
      );
      app.delete(record);
    } catch {
      // silent errors (probably already deleted)
    }
  }
);
