﻿--Migration
--Migration
EXEC dev.uspDropDefaultConstraint @pTableName = 'T_ERTEKELESTANTARGYI', @pColumnName = 'T_ERTEKELESTANTARGYI'
GO
PRINT N'Dropping Index [dbo].[T_ERTEKELESTANTARGYI].[NCI_ErtekelesTantargyi_IntezmenyId_TanevId_ErtekelesModId]...';


GO
DROP INDEX [NCI_ErtekelesTantargyi_IntezmenyId_TanevId_ErtekelesModId]
    ON [dbo].[T_ERTEKELESTANTARGYI];


GO
PRINT N'Dropping Foreign Key [dbo].[FK_ErtekelesTantargyi_ErtekelesModId_IntezmenyId_TanevId_REF_ErtekelesMod]...';


GO
ALTER TABLE [dbo].[T_ERTEKELESTANTARGYI] DROP CONSTRAINT [FK_ErtekelesTantargyi_ErtekelesModId_IntezmenyId_TanevId_REF_ErtekelesMod];


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


GO
ALTER TABLE [dbo].[T_ERTEKELESTANTARGYI] ALTER COLUMN [C_ERTEKELESMODID] INT NULL;


GO
PRINT N'Creating Index [dbo].[T_ERTEKELESTANTARGYI].[NCI_ErtekelesTantargyi_IntezmenyId_TanevId_ErtekelesModId]...';


GO
CREATE NONCLUSTERED INDEX [NCI_ErtekelesTantargyi_IntezmenyId_TanevId_ErtekelesModId]
    ON [dbo].[T_ERTEKELESTANTARGYI]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_ERTEKELESMODID] ASC);


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


GO
ALTER TABLE [dbo].[T_ERTEKELESTANTARGYI] WITH NOCHECK
    ADD CONSTRAINT [FK_ErtekelesTantargyi_ErtekelesModId_IntezmenyId_TanevId_REF_ErtekelesMod] FOREIGN KEY ([C_ERTEKELESMODID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_ERTEKELESMOD] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


EXEC dev.uspCreateSchemaViews 'T_ERTEKELESTANTARGYI'
GO

EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll
GO

GO
ALTER TABLE [dbo].[T_ERTEKELESTANTARGYI] WITH CHECK CHECK CONSTRAINT [FK_ErtekelesTantargyi_ErtekelesModId_IntezmenyId_TanevId_REF_ErtekelesMod];


GO
PRINT N'Update complete.';


GO
