﻿PRINT N'Altering Table [dbo].[T_FELHASZNALO]...';


GO
ALTER TABLE [dbo].[T_FELHASZNALO]
    ADD [C_ISADOAZONOSITONELKUL] CHAR (1) DEFAULT ('F') NOT NULL,
        [C_ISOKTAZONNELKUL]      CHAR (1) DEFAULT ('F') NOT NULL,
        [C_ISTAJSZAMNELKUL]      CHAR (1) DEFAULT ('F') NOT NULL;


GO
PRINT N'Creating Table [dbo].[T_ESZKOZIGENYLES]...';


GO
CREATE TABLE [dbo].[T_ESZKOZIGENYLES] (
    [ID]                   INT      IDENTITY (1, 1) NOT NULL,
    [C_ASZFELFOGADASIDEJE] DATETIME NOT NULL,
    [C_ISELFOGADOTTASZF]   CHAR (1) NOT NULL,
    [C_ISESZKOZKIOSZTVA]   CHAR (1) NOT NULL,
    [C_GONDVISELOID]       INT      NOT NULL,
    [C_TANULOID]           INT      NOT NULL,
    [C_ALKALMAZOTTID]      INT      NOT 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,
    CONSTRAINT [PK_EszkozIgenyles] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating Index [dbo].[T_ESZKOZIGENYLES].[NCI_EszkozIgenyles_GondviseloId]...';


GO
CREATE NONCLUSTERED INDEX [NCI_EszkozIgenyles_GondviseloId]
    ON [dbo].[T_ESZKOZIGENYLES]([C_GONDVISELOID] ASC);


GO
PRINT N'Creating Index [dbo].[T_ESZKOZIGENYLES].[NCI_EszkozIgenyles_TanuloId]...';


GO
CREATE NONCLUSTERED INDEX [NCI_EszkozIgenyles_TanuloId]
    ON [dbo].[T_ESZKOZIGENYLES]([C_TANULOID] ASC);


GO
PRINT N'Creating Index [dbo].[T_ESZKOZIGENYLES].[NCI_EszkozIgenyles_AlkalmazottId]...';


GO
CREATE NONCLUSTERED INDEX [NCI_EszkozIgenyles_AlkalmazottId]
    ON [dbo].[T_ESZKOZIGENYLES]([C_ALKALMAZOTTID] ASC);


GO
PRINT N'Creating Index [dbo].[T_ESZKOZIGENYLES].[NCI_EszkozIgenyles_IntezmenyId]...';


GO
CREATE NONCLUSTERED INDEX [NCI_EszkozIgenyles_IntezmenyId]
    ON [dbo].[T_ESZKOZIGENYLES]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating Index [dbo].[T_ESZKOZIGENYLES].[NCI_EszkozIgenyles_TanevId]...';


GO
CREATE NONCLUSTERED INDEX [NCI_EszkozIgenyles_TanevId]
    ON [dbo].[T_ESZKOZIGENYLES]([C_TANEVID] ASC);


GO
PRINT N'Creating Default Constraint unnamed constraint on [dbo].[T_ESZKOZIGENYLES]...';


GO
ALTER TABLE [dbo].[T_ESZKOZIGENYLES]
    ADD DEFAULT ('F') FOR [C_ISELFOGADOTTASZF];


GO
PRINT N'Creating Default Constraint unnamed constraint on [dbo].[T_ESZKOZIGENYLES]...';


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


GO
PRINT N'Creating Default Constraint unnamed constraint on [dbo].[T_ESZKOZIGENYLES]...';


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


GO
PRINT N'Creating Default Constraint unnamed constraint on [dbo].[T_ESZKOZIGENYLES]...';


GO
ALTER TABLE [dbo].[T_ESZKOZIGENYLES]
    ADD DEFAULT ('F') FOR [C_ISESZKOZKIOSZTVA];


GO
PRINT N'Creating Default Constraint unnamed constraint on [dbo].[T_ESZKOZIGENYLES]...';


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


GO
PRINT N'Creating Default Constraint unnamed constraint on [dbo].[T_ESZKOZIGENYLES]...';


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


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


GO
ALTER TABLE [dbo].[T_ESZKOZIGENYLES] WITH NOCHECK
    ADD CONSTRAINT [FK_EszkozIgenyles_GondviseloId_REF_Gondviselo] FOREIGN KEY ([C_GONDVISELOID]) REFERENCES [dbo].[T_GONDVISELO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_ESZKOZIGENYLES] WITH NOCHECK
    ADD CONSTRAINT [FK_EszkozIgenyles_TanuloId_REF_Tanulo] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_ESZKOZIGENYLES] WITH NOCHECK
    ADD CONSTRAINT [FK_EszkozIgenyles_AlkalmazottId_REF_Alkalmazott] FOREIGN KEY ([C_ALKALMAZOTTID]) REFERENCES [dbo].[T_ALKALMAZOTT] ([ID]);


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


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


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


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


GO

EXECUTE dev.uspCreateSchemaViews 'T_FELHASZNALO,T_ESZKOZIGENYLES'
EXECUTE dev.sp_Global_GenerateAsyncAuditTriggerAll
GO

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

PRINT N'Update complete.';

GO
