﻿--Migration
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

SET NUMERIC_ROUNDABORT OFF;
GO

DROP INDEX IF EXISTS [NCI_Tanulo_TantervId] ON [dbo].[T_TANULO];
GO

ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT IF EXISTS [FK_Tanulo_TantervId_REF_Tanterv];
GO

ALTER TABLE [dbo].[T_TANULO] ALTER COLUMN [C_TANTERVID] INT NULL;
GO

CREATE NONCLUSTERED INDEX [NCI_Tanulo_TantervId] ON [dbo].[T_TANULO]([C_TANTERVID] ASC);
GO

ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK ADD CONSTRAINT [FK_Tanulo_TantervId_REF_Tanterv] FOREIGN KEY ([C_TANTERVID]) REFERENCES [dbo].[T_TANTERV] ([ID]);
GO

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_Tanulo_TantervId_REF_Tanterv];
GO

EXEC dev.uspDropDefaultConstraint @pTableName = 'T_TANULO', @pColumnName =  'C_TANTERVID';
GO

EXEC dev.uspCreateSchemaViews 'T_TANULO';
GO

EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll;
GO

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