# -*- coding: utf-8 -*-

from ppms import ppms
from ppms.migration import SQLPacket, PacketCategory, VersionType, MinVersionDependency
from ppms.constants import DBMS_MSSQL

__all__ = ['RebuildTableIndicesVenusMSSQL']

class RebuildTableIndicesVenusMSSQL(SQLPacket):
    """Rebuilds tableindices on MSSQL
    """
    version = 1
    run_on_startup = True
    done_after_success = False
    category = PacketCategory.CATEGORY_HELPER
    wi_number = 13952
    special_snowflake = True

    def get_dependencies(self):
        return (MinVersionDependency(version='39.5', version_type=VersionType.CUSTOMIZING),)

    def fix(self, runner):
        if (ppms.db_get_dbms_name() == DBMS_MSSQL):
            sql_file = "wi13952_rebuild_tableindices_venus.sql"
            self.apply_fix_ddl_file(self.sql_planta_de_dbms, sql_file)

        return self.success()