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

SET NUMERIC_ROUNDABORT OFF;

GO
PRINT N'Dropping [dbo].[T_FELTOLTOTTFAJL].[I_T_4028886_4028884]...';


GO
DROP INDEX [I_T_4028886_4028884]
    ON [dbo].[T_FELTOLTOTTFAJL];


GO
PRINT N'Dropping [dbo].[T_FELTOLTOTTFAJL].[I_T_4028889_4028887]...';


GO
DROP INDEX [I_T_4028889_4028887]
    ON [dbo].[T_FELTOLTOTTFAJL];


GO
PRINT N'Dropping [dbo].[T_FELTOLTOTTFAJL].[NCU_FeltoltottFajl_DokumentumTeremId]...';


GO
DROP INDEX [NCU_FeltoltottFajl_DokumentumTeremId]
    ON [dbo].[T_FELTOLTOTTFAJL];


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


GO
ALTER TABLE [dbo].[T_FELTOLTOTTFAJL] DROP CONSTRAINT [FK_4028886_4028884];


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


GO
ALTER TABLE [dbo].[T_FELTOLTOTTFAJL] DROP CONSTRAINT [FK_4028889_4028887];


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


GO
ALTER TABLE [dbo].[T_FELTOLTOTTFAJL] DROP COLUMN [C_DOKUMENTUMTEREMID], COLUMN [C_KEPTEREMID];


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


GO
CREATE TABLE [dbo].[T_TEREM_FELTOLTOTTFAJL] (
    [ID]                  INT      IDENTITY (1, 1) NOT NULL,
    [C_ISDOKUMENTUM]      CHAR (1) NOT NULL,
    [C_INTEZMENYID]       INT      NOT NULL,
    [C_TANEVID]           INT      NOT NULL,
    [C_FELTOLTOTTFAJLID]  INT      NOT NULL,
    [C_TEREMID]           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_4028907] PRIMARY KEY NONCLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_TEREM_FELTOLTOTTFAJL].[CU_Terem_FeltoltottFajl_TeremId_FeltoltottFajlId]...';


GO
CREATE UNIQUE CLUSTERED INDEX [CU_Terem_FeltoltottFajl_TeremId_FeltoltottFajlId]
    ON [dbo].[T_TEREM_FELTOLTOTTFAJL]([C_TEREMID] ASC, [C_FELTOLTOTTFAJLID] ASC) WITH (FILLFACTOR = 80);


GO
PRINT N'Creating [dbo].[T_TEREM_FELTOLTOTTFAJL].[I_T_402890702_402890700]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402890702_402890700]
    ON [dbo].[T_TEREM_FELTOLTOTTFAJL]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TEREM_FELTOLTOTTFAJL].[I_T_402890705_402890703]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402890705_402890703]
    ON [dbo].[T_TEREM_FELTOLTOTTFAJL]([C_TANEVID] ASC);


GO
PRINT N'Creating [dbo].[T_TEREM_FELTOLTOTTFAJL].[I_T_4028910_4028909]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028910_4028909]
    ON [dbo].[T_TEREM_FELTOLTOTTFAJL]([C_FELTOLTOTTFAJLID] ASC);


GO
PRINT N'Creating [dbo].[T_TEREM_FELTOLTOTTFAJL].[I_T_4028911_4028909]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028911_4028909]
    ON [dbo].[T_TEREM_FELTOLTOTTFAJL]([C_TEREMID] ASC);


GO
PRINT N'Creating [dbo].[T_TEREM_FELTOLTOTTFAJL].[NCU_Terem_FeltoltottFajl_TeremId]...';


GO
CREATE UNIQUE NONCLUSTERED INDEX [NCU_Terem_FeltoltottFajl_TeremId]
    ON [dbo].[T_TEREM_FELTOLTOTTFAJL]([C_TEREMID] ASC) WHERE ([C_ISDOKUMENTUM]='T') WITH (FILLFACTOR = 80);


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


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


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


GO
ALTER TABLE [dbo].[T_TEREM_FELTOLTOTTFAJL]
    ADD DEFAULT ('F') FOR [C_ISDOKUMENTUM];


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TEREM_FELTOLTOTTFAJL] WITH NOCHECK
    ADD CONSTRAINT [FK_4028910_4028909] FOREIGN KEY ([C_FELTOLTOTTFAJLID]) REFERENCES [dbo].[T_FELTOLTOTTFAJL] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TEREM_FELTOLTOTTFAJL] WITH NOCHECK
    ADD CONSTRAINT [FK_4028911_4028909] FOREIGN KEY ([C_TEREMID]) REFERENCES [dbo].[T_TEREM] ([ID]);


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


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