
----------------------------------------------------------------后端服务启动前执行-----------------------------------------------------------------------------------------
##MongoDB 属性相关迁移脚本

##将 paperStruct 表相关字段类型由Long改为String

db.paperStruct.find().forEach( function (doc) {
	if(doc.coursePropertyId !=null || doc.paperDetailStructs!=null){
		if(doc.coursePropertyId !=null){
			doc.coursePropertyId=doc.coursePropertyId+"";
		}
		if(doc.paperDetailStructs!=null){
			doc.paperDetailStructs.forEach( function (detail) {
				if(detail.coursePropertyNumberDtos!=null){
					detail.coursePropertyNumberDtos.forEach( function (courseProperty) {
						courseProperty._id=courseProperty._id+"";
						courseProperty.propertyParentId=courseProperty.propertyParentId+"";
						courseProperty.propertyId=courseProperty.propertyId+"";
					});
				}
			});
		}
		db.paperStruct.save(doc);
	}
});

##将 question 表相关字段类型由Long改为String

db.question.find().forEach( function (doc) {
	if(doc.quesProperties !=null){
		doc.quesProperties.forEach( function (pros) {
			if(pros.firstProperty !=null){
				pros.firstProperty._id=pros.firstProperty._id+"";
				pros.firstProperty.coursePropertyId=pros.firstProperty.coursePropertyId+"";
				pros.firstProperty.parentId=pros.firstProperty.parentId+"";
			}
			if(pros.secondProperty !=null){
				pros.secondProperty._id=pros.secondProperty._id+"";
				pros.secondProperty.coursePropertyId=pros.secondProperty.coursePropertyId+"";
				pros.secondProperty.parentId=pros.secondProperty.parentId+"";
			}
		});
		db.question.save(doc);
	}
});



----------------------------------------------------------------后端服务启动后执行------------------------------------------------------------------------------------------




