# -*- coding: utf-8 -*-
from ppms import ppms
from ppms.migration import SQLPacket, PacketCategory, MaxVersionDependency, VersionType
from ppms.constants import DBMS_ORACLE, DBMS_MSSQL


class PortfolioSimulation(SQLPacket):
    """Adds required columns for the new portfolio simulation."""
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 20085

    sql_script = 'WI20085_portfolio_simulation.sql'

    def get_dependencies(self):
        return MaxVersionDependency(version='39.5.9', version_type=VersionType.CUSTOMIZING),

    def fix(self, packet_runner):
        if self.DBMS == DBMS_ORACLE:
            self.apply_fix_ddl_file(self.sql_planta_de_dbms, self.sql_script, split=True)
        elif self.DBMS == DBMS_MSSQL:
            self.apply_fix_ddl_file(self.sql_planta_de_dbms, self.sql_script, split=True, separator='GO$')
        
        return self.success()
