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

export const runServiceRuntimeOptionalsMigration = async (
  databaseArg: OneboxDatabase,
): Promise<void> => {
  await databaseArg.db.mongoDb.collection('ServiceDoc').updateMany(
    {
      $or: [
        { containerArgs: null },
        { secretFiles: null },
        { imageCleanup: null },
      ],
    },
    {
      $unset: {
        containerArgs: '',
        secretFiles: '',
        imageCleanup: '',
      },
    },
    { upsert: false },
  );
};
