import { Model } from 'mongoose';
import { ConfigDocument } from '../config.model';
import { Migration } from '../registry/migration.interface';

export const migration_v5: Migration = {
	version: 5,
	name: 'Add free_models config if not exists',
	up: async (configModel: Model<ConfigDocument>) => {
		console.log('Migration 5: up - starting free_models config migration');
		
		await configModel.findOneAndUpdate(
			{ key: 'free_models' },
			{ 
				key: 'free_models', 
				value: '0',
				description: 'Number of free models available'
			},
			{ upsert: true, new: true }
		);
		
		console.log('Migration 5: up - free_models config migration completed');
	}
};

