﻿GO
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

SET NUMERIC_ROUNDABORT OFF;


GO
/*
The column C_KOZOSSEGISZOLGALAT on table [dbo].[T_TANULOKOZOSSEGISZOLGALAT] must be changed from NULL to NOT NULL. If the table contains data, the ALTER script may not work. To avoid this issue, you must add values to this column for all rows or mark it as allowing NULL values, or enable the generation of smart-defaults as a deployment option.
*/

/*IF EXISTS (select top 1 1 from [dbo].[T_TANULOKOZOSSEGISZOLGALAT])
    RAISERROR (N'Rows were detected. The schema update is terminating because data loss might occur.', 16, 127) WITH NOWAIT*/

GO
PRINT N'Dropping [dbo].[T_TANULOKOZOSSEGISZOLGALAT].[I_T_4026172_4027909]...';


GO
DROP INDEX [I_T_4026172_4027909]
    ON [dbo].[T_TANULOKOZOSSEGISZOLGALAT];


GO
PRINT N'Dropping [dbo].[FK_4026172_4027909]...';


GO
ALTER TABLE [dbo].[T_TANULOKOZOSSEGISZOLGALAT] DROP CONSTRAINT [FK_4026172_4027909];


GO
PRINT N'Altering [dbo].[T_TANULOKOZOSSEGISZOLGALAT]...';


GO
ALTER TABLE [dbo].[T_TANULOKOZOSSEGISZOLGALAT] ALTER COLUMN [C_KOZOSSEGISZOLGALAT] INT NOT NULL;


GO
PRINT N'Creating [dbo].[T_TANULOKOZOSSEGISZOLGALAT].[I_T_4026172_4027909]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026172_4027909]
    ON [dbo].[T_TANULOKOZOSSEGISZOLGALAT]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_KOZOSSEGISZOLGALAT] ASC);


GO
PRINT N'Creating [dbo].[FK_4026172_4027909]...';


GO
ALTER TABLE [dbo].[T_TANULOKOZOSSEGISZOLGALAT] WITH NOCHECK
    ADD CONSTRAINT [FK_4026172_4027909] FOREIGN KEY ([C_KOZOSSEGISZOLGALAT], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_KOZOSSEGISZOLGALATTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Refreshing [dbo].[T_TANULOKOZOSSEGISZOLGALAT_OSSZES]...';


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


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


GO
ALTER TABLE [dbo].[T_TANULOKOZOSSEGISZOLGALAT] WITH CHECK CHECK CONSTRAINT [FK_4026172_4027909];


GO
PRINT N'Update complete.';


GO
