﻿DROP INDEX IF EXISTS T_TANULOMULASZTAS.NCI_TanuloMulasztas_TanitasiOrakId_TanevId_IntezmenyId_Tipus
GO
CREATE INDEX NCI_TanuloMulasztas_TanitasiOrakId_TanevId_IntezmenyId_Tipus
ON T_TANULOMULASZTAS(
   C_TANITASIORAKID
  ,C_TANEVID
  ,C_INTEZMENYID
  ,C_TIPUS
  )
INCLUDE(C_IGAZOLT,C_KESESPERCBEN,C_ORATANULOIID,C_IGAZOLASTIPUSA)
WHERE TOROLT='F'
WITH (FILLFACTOR = 80)

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'CI_EntityAttributeHistory_EntityHistoryId_PropertyName')
BEGIN
  ALTER TABLE T_ENTITYATTRIBUTEHISTORY DROP CONSTRAINT IF EXISTS PK_EntityAttributeHistory
  DROP INDEX IF EXISTS T_ENTITYATTRIBUTEHISTORY.CI_EntityAttributeHistory_EntityHistoryId_PropertyName
  CREATE CLUSTERED INDEX CI_EntityAttributeHistory_EntityHistoryId_PropertyName ON T_ENTITYATTRIBUTEHISTORY (
     C_ENTITYHISTORYID
    ,C_PROPERTYNAME
  ) WITH FILLFACTOR = 80

  ALTER TABLE T_ENTITYATTRIBUTEHISTORY ADD CONSTRAINT PK_EntityAttributeHistory PRIMARY KEY(ID)
END

ALTER TABLE T_ORARENDIORA DROP CONSTRAINT IF EXISTS FK_OrarendiOra_FoglalkozasId_REF_Foglalkozas
ALTER TABLE T_TANITASIORA DROP CONSTRAINT IF EXISTS FK_TanitasiOra_FoglalkozasId_REF_Foglalkozas