﻿--Migration

GO
PRINT N'Altering Table [dbo].[T_TANULOTANUGYIADATOK]...';


GO
ALTER TABLE [dbo].[T_TANULOTANUGYIADATOK]
    ADD [C_TANTERVIJELLEGID] INT NULL;


GO
PRINT N'Creating Index [dbo].[T_TANULOTANUGYIADATOK].[NCI_TanuloTanugyiAdatok_IntezmenyId_TanevId_TanterviJellegId]...';


GO
CREATE NONCLUSTERED INDEX [NCI_TanuloTanugyiAdatok_IntezmenyId_TanevId_TanterviJellegId]
    ON [dbo].[T_TANULOTANUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_TANTERVIJELLEGID] ASC);


GO
PRINT N'Creating Foreign Key [dbo].[FK_TanuloTanugyiAdatok_TanterviJellegId_IntezmenyId_TanevId_REF_TanterviJelleg]...';


GO
ALTER TABLE [dbo].[T_TANULOTANUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_TanuloTanugyiAdatok_TanterviJellegId_IntezmenyId_TanevId_REF_TanterviJelleg] FOREIGN KEY ([C_TANTERVIJELLEGID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_TANTERVIJELLEG] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Refreshing View [dbo].[T_TANULOTANUGYIADATOK_OSSZES]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[T_TANULOTANUGYIADATOK_OSSZES]';


GO
PRINT N'Refreshing View [dbo].[V_TANULOCSOPORT]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[V_TANULOCSOPORT]';


GO
PRINT N'Checking existing data against newly created constraints';


GO


GO
ALTER TABLE [dbo].[T_TANULOTANUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_TanuloTanugyiAdatok_TanterviJellegId_IntezmenyId_TanevId_REF_TanterviJelleg];


GO
PRINT N'Update complete.';


GO

EXEC dev.uspCreateSchemaViews 'T_TANULOTANUGYIADATOK'
GO
EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll
GO

ALTER QUEUE auditLog.[AuditQueue]
WITH ACTIVATION (
  STATUS = ON,
  PROCEDURE_NAME = auditLog.usp_AuditProcessing,
  MAX_QUEUE_READERS = 10,
  EXECUTE AS 'Kreta_tech_user'
);
GO

