package com.iqser.red.service.persistence.management.v1.processor.migration.migrations;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iqser.red.service.persistence.management.v1.processor.migration.Migration;
import com.iqser.red.service.persistence.management.v1.processor.migration.RankDeDuplicationService;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Setter
@Service
public class V16RankDeDuplicationMigration extends Migration {

    @Autowired
    private RankDeDuplicationService rankDeDuplicationService;


    public V16RankDeDuplicationMigration() {

        super(NAME, VERSION);
    }


    private static final String NAME = "Adding to the migration the rank de-duplication";
    private static final long VERSION = 16;


    @Override
    /*
     * In cases were we have duplicate ranks for entities, this needs to be fixed
     */ protected void migrate() {

        log.info("Migration: Checking for duplicate ranks");
        rankDeDuplicationService.deduplicate();

    }

}
