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

SET NUMERIC_ROUNDABORT OFF;


--GO
--/*
--The column [dbo].[T_ORARENDSABLON].[C_ORARENDID] is being dropped, data loss could occur.
--*/

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

--GO
--/*
--Table [dbo].[T_ORAREND] is being dropped.  Deployment will halt if the table contains data.
--*/

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

--GO
--/*
--Table [dbo].[T_ORARENDORATULAJDONSAG] is being dropped.  Deployment will halt if the table contains data.
--*/

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

--GO
--/*
--Table [dbo].[T_TANORA] is being dropped.  Deployment will halt if the table contains data.
--*/

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

--GO
--/*
--Table [dbo].[T_TANORAORATULAJDONSAG] is being dropped.  Deployment will halt if the table contains data.
--*/

--IF EXISTS (select top 1 1 from [dbo].[T_TANORAORATULAJDONSAG])
--    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_ORARENDSABLON].[I_T_4028014_4028012]...';


GO
DROP INDEX [I_T_4028014_4028012]
    ON [dbo].[T_ORARENDSABLON];


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


GO
ALTER TABLE [dbo].[T_ORARENDORATULAJDONSAG] DROP CONSTRAINT [FK_4028020_4028018];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4028016_4028015];


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


GO
ALTER TABLE [dbo].[T_ORARENDSABLON] DROP CONSTRAINT [FK_4028014_4028012];


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


GO
ALTER TABLE [dbo].[T_TANORAORATULAJDONSAG] DROP CONSTRAINT [FK_4028011_4028009];


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


GO
ALTER TABLE [dbo].[T_ORAREND] DROP CONSTRAINT [FK_4028008_4028006];


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


GO
ALTER TABLE [dbo].[T_ORAREND] DROP CONSTRAINT [FK_4028023_4028021];


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


GO
ALTER TABLE [dbo].[T_ORAREND] DROP CONSTRAINT [FK_4028026_4028024];


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


GO
ALTER TABLE [dbo].[T_ORAREND] DROP CONSTRAINT [FK_4028029_4028027];


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


GO
ALTER TABLE [dbo].[T_ORAREND] DROP CONSTRAINT [FK_402795602_402795600];


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


GO
ALTER TABLE [dbo].[T_ORAREND] DROP CONSTRAINT [FK_402795605_402795603];


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


GO
ALTER TABLE [dbo].[T_ORAREND] DROP CONSTRAINT [FK_4027956_4027960];


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


GO
ALTER TABLE [dbo].[T_ORAREND] DROP CONSTRAINT [FK_4027956_4027961];


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


GO
ALTER TABLE [dbo].[T_ORARENDORATULAJDONSAG] DROP CONSTRAINT [FK_402799802_402799800];


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


GO
ALTER TABLE [dbo].[T_ORARENDORATULAJDONSAG] DROP CONSTRAINT [FK_402799805_402799803];


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


GO
ALTER TABLE [dbo].[T_ORARENDORATULAJDONSAG] DROP CONSTRAINT [FK_4027998_4027999];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4028002_4028000];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4028005_4028003];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4028032_4028030];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4028035_4028033];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4028041_4028039];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4028044_4028042];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_402797702_402797700];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_402797705_402797703];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4027977_4027984];


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


GO
ALTER TABLE [dbo].[T_TANORA] DROP CONSTRAINT [FK_4027977_4027986];


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


GO
ALTER TABLE [dbo].[T_TANORAORATULAJDONSAG] DROP CONSTRAINT [FK_402795402_402795400];


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


GO
ALTER TABLE [dbo].[T_TANORAORATULAJDONSAG] DROP CONSTRAINT [FK_402795405_402795403];


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


GO
ALTER TABLE [dbo].[T_TANORAORATULAJDONSAG] DROP CONSTRAINT [FK_4027954_4027955];


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


GO
DROP VIEW [dbo].[T_ORAREND_OSSZES];


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


GO
DROP VIEW [dbo].[T_ORARENDORATULAJDONSAG_OSSZES];


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


GO
DROP VIEW [dbo].[T_TANORA_OSSZES];


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


GO
DROP VIEW [dbo].[T_TANORAORATULAJDONSAG_OSSZES];


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


GO
DROP TABLE [dbo].[T_ORAREND];


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


GO
DROP TABLE [dbo].[T_ORARENDORATULAJDONSAG];


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


GO
DROP TABLE [dbo].[T_TANORA];


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


GO
DROP TABLE [dbo].[T_TANORAORATULAJDONSAG];


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


GO
ALTER TABLE [dbo].[T_ORARENDSABLON] DROP COLUMN [C_ORARENDID];


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


GO
CREATE TABLE [dbo].[T_ORARENDIORATULAJDONSAG] (
    [ID]                  INT      IDENTITY (1, 1) NOT NULL,
    [C_ORATULAJDONSAGID]  INT      NULL,
    [C_INTEZMENYID]       INT      NOT NULL,
    [C_TANEVID]           INT      NOT NULL,
    [TOROLT]              CHAR (1) NOT NULL,
    [SERIAL]              INT      NOT NULL,
    [LASTCHANGED]         DATETIME NOT NULL,
    [CREATED]             DATETIME NOT NULL,
    [MODIFIER]            INT      NULL,
    [CREATOR]             INT      NULL,
    [ELOZOTANEVIREKORDID] INT      NULL,
    [NNID]                INT      NULL,
    CONSTRAINT [PK_T_4027998] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_ORARENDIORATULAJDONSAG].[I_T_4027998_4027999]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027998_4027999]
    ON [dbo].[T_ORARENDIORATULAJDONSAG]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_ORATULAJDONSAGID] ASC);


GO
PRINT N'Creating [dbo].[T_ORARENDIORATULAJDONSAG].[I_T_402799802_402799800]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402799802_402799800]
    ON [dbo].[T_ORARENDIORATULAJDONSAG]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_ORARENDIORATULAJDONSAG].[I_T_402799805_402799803]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402799805_402799803]
    ON [dbo].[T_ORARENDIORATULAJDONSAG]([C_TANEVID] ASC);


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


GO
CREATE TABLE [dbo].[T_TANITASIORATULAJDONSAG] (
    [ID]                  INT      IDENTITY (1, 1) NOT NULL,
    [C_ORATULAJDONSAGID]  INT      NULL,
    [C_INTEZMENYID]       INT      NOT NULL,
    [C_TANEVID]           INT      NOT NULL,
    [TOROLT]              CHAR (1) NOT NULL,
    [SERIAL]              INT      NOT NULL,
    [LASTCHANGED]         DATETIME NOT NULL,
    [CREATED]             DATETIME NOT NULL,
    [MODIFIER]            INT      NULL,
    [CREATOR]             INT      NULL,
    [ELOZOTANEVIREKORDID] INT      NULL,
    [NNID]                INT      NULL,
    CONSTRAINT [PK_T_4027954] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_TANITASIORATULAJDONSAG].[I_T_4027954_4027955]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027954_4027955]
    ON [dbo].[T_TANITASIORATULAJDONSAG]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_ORATULAJDONSAGID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORATULAJDONSAG].[I_T_402795402_402795400]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402795402_402795400]
    ON [dbo].[T_TANITASIORATULAJDONSAG]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORATULAJDONSAG].[I_T_402795405_402795403]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402795405_402795403]
    ON [dbo].[T_TANITASIORATULAJDONSAG]([C_TANEVID] ASC);


GO
PRINT N'Creating unnamed constraint on [dbo].[T_ORARENDIORATULAJDONSAG]...';


GO
ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG]
    ADD DEFAULT (getdate()) FOR [LASTCHANGED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_ORARENDIORATULAJDONSAG]...';


GO
ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG]
    ADD DEFAULT ((0)) FOR [SERIAL];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_ORARENDIORATULAJDONSAG]...';


GO
ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG]
    ADD DEFAULT ('F') FOR [TOROLT];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_ORARENDIORATULAJDONSAG]...';


GO
ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG]
    ADD DEFAULT (getdate()) FOR [CREATED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_TANITASIORATULAJDONSAG]...';


GO
ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG]
    ADD DEFAULT (getdate()) FOR [LASTCHANGED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_TANITASIORATULAJDONSAG]...';


GO
ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG]
    ADD DEFAULT ('F') FOR [TOROLT];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_TANITASIORATULAJDONSAG]...';


GO
ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG]
    ADD DEFAULT ((0)) FOR [SERIAL];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_TANITASIORATULAJDONSAG]...';


GO
ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG]
    ADD DEFAULT (getdate()) FOR [CREATED];


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


GO
ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG] WITH NOCHECK
    ADD CONSTRAINT [FK_4027998_4027999] FOREIGN KEY ([C_ORATULAJDONSAGID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_ORATULAJDONSAGTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG] WITH NOCHECK
    ADD CONSTRAINT [FK_402799802_402799800] FOREIGN KEY ([C_INTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG] WITH NOCHECK
    ADD CONSTRAINT [FK_402799805_402799803] FOREIGN KEY ([C_TANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG] WITH NOCHECK
    ADD CONSTRAINT [FK_402795402_402795400] FOREIGN KEY ([C_INTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG] WITH NOCHECK
    ADD CONSTRAINT [FK_402795405_402795403] FOREIGN KEY ([C_TANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG] WITH NOCHECK
    ADD CONSTRAINT [FK_4027954_4027955] FOREIGN KEY ([C_ORATULAJDONSAGID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_ORATULAJDONSAGTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


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


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


GO
ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG] WITH CHECK CHECK CONSTRAINT [FK_4027998_4027999];

ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG] WITH CHECK CHECK CONSTRAINT [FK_402799802_402799800];

ALTER TABLE [dbo].[T_ORARENDIORATULAJDONSAG] WITH CHECK CHECK CONSTRAINT [FK_402799805_402799803];

ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG] WITH CHECK CHECK CONSTRAINT [FK_402795402_402795400];

ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG] WITH CHECK CHECK CONSTRAINT [FK_402795405_402795403];

ALTER TABLE [dbo].[T_TANITASIORATULAJDONSAG] WITH CHECK CHECK CONSTRAINT [FK_4027954_4027955];


GO
PRINT N'Update complete.';


GO
