import type { OneboxDatabase } from '../ts/database/index.js';

export const runPasskeyOnlyAuthMigration = async (
  databaseArg: OneboxDatabase,
): Promise<void> => {
  await databaseArg.db.mongoDb.collection('UserDoc').updateMany(
    {
      'passkeyCredentials.0': { $exists: true },
      passwordHash: { $exists: true },
    },
    {
      $unset: { passwordHash: '' },
    },
    { upsert: false },
  );
};
