﻿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_ORARENDIORA].[C_TANORANKIVULIFOGLALKOZAS].[MS_Description]...';


GO
EXECUTE sp_dropextendedproperty @name = N'MS_Description', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_ORARENDIORA', @level2type = N'COLUMN', @level2name = N'C_TANORANKIVULIFOGLALKOZAS';


GO
PRINT N'Dropping [dbo].[T_OSZTALY].[C_TECHNIKAIOSZTALY].[MS_Description]...';


GO
EXECUTE sp_dropextendedproperty @name = N'MS_Description', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_OSZTALY', @level2type = N'COLUMN', @level2name = N'C_TECHNIKAIOSZTALY';


GO
PRINT N'Dropping [dbo].[T_TANITASIORA].[C_TANORANKIVULIFOGLALKOZAS].[MS_Description]...';


GO
EXECUTE sp_dropextendedproperty @name = N'MS_Description', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANITASIORA', @level2type = N'COLUMN', @level2name = N'C_TANORANKIVULIFOGLALKOZAS';


GO
DECLARE @sql NVARCHAR(MAX) = ''

SELECT @sql += 'ALTER TABLE ' + tables.name + ' DROP CONSTRAINT IF EXISTS ' + default_constraints.name + ';' + char(13) + char(10)
FROM sys.all_columns
  INNER JOIN sys.tables ON all_columns.object_id = tables.object_id
  INNER JOIN sys.schemas ON tables.schema_id = schemas.schema_id
  INNER JOIN sys.default_constraints ON all_columns.default_object_id = default_constraints.object_id
WHERE schemas.name = 'dbo'
  AND tables.name = 'T_ORARENDIORA'
  AND all_columns.name IN ('C_TANORANKIVULIFOGLALKOZAS')

  SELECT @sql += 'ALTER TABLE ' + tables.name + ' DROP CONSTRAINT IF EXISTS ' + default_constraints.name + ';' + char(13) + char(10)
FROM sys.all_columns
  INNER JOIN sys.tables ON all_columns.object_id = tables.object_id
  INNER JOIN sys.schemas ON tables.schema_id = schemas.schema_id
  INNER JOIN sys.default_constraints ON all_columns.default_object_id = default_constraints.object_id
WHERE schemas.name = 'dbo'
  AND tables.name = 'T_TANULO'
  AND all_columns.name IN ('C_SNILETSZAMSULY')

  SELECT @sql += 'ALTER TABLE ' + tables.name + ' DROP CONSTRAINT IF EXISTS ' + default_constraints.name + ';' + char(13) + char(10)
FROM sys.all_columns
  INNER JOIN sys.tables ON all_columns.object_id = tables.object_id
  INNER JOIN sys.schemas ON tables.schema_id = schemas.schema_id
  INNER JOIN sys.default_constraints ON all_columns.default_object_id = default_constraints.object_id
WHERE schemas.name = 'dbo'
  AND tables.name = 'T_TANITASIORA'
  AND all_columns.name IN ('C_TANORANKIVULIFOGLALKOZAS')

  SELECT @sql += 'ALTER TABLE ' + tables.name + ' DROP CONSTRAINT IF EXISTS ' + default_constraints.name + ';' + char(13) + char(10)
FROM sys.all_columns
  INNER JOIN sys.tables ON all_columns.object_id = tables.object_id
  INNER JOIN sys.schemas ON tables.schema_id = schemas.schema_id
  INNER JOIN sys.default_constraints ON all_columns.default_object_id = default_constraints.object_id
WHERE schemas.name = 'dbo'
  AND tables.name = 'T_OSZTALY'
  AND all_columns.name IN ('C_TECHNIKAIOSZTALY')


EXEC sp_executesql @sql 

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


GO
ALTER TABLE [dbo].[T_FELHASZNALO]
    ADD [C_MEGJEGYZES] NVARCHAR (500) NULL;


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


GO
ALTER TABLE [dbo].[T_ORARENDIORA] DROP COLUMN [C_TANORANKIVULIFOGLALKOZAS];


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


GO
ALTER TABLE [dbo].[T_OSZTALYCSOPORT]
    ADD [C_ISTECHNIKAI] CHAR (1) DEFAULT ('F') NOT NULL;

GO
UPDATE ocs
SET ocs.C_ISTECHNIKAI = o.C_TECHNIKAIOSZTALY
FROM T_OSZTALYCSOPORT ocs
INNER JOIN T_OSZTALY o ON o.ID = ocs.ID


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


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP COLUMN [C_TECHNIKAIOSZTALY];



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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP COLUMN [C_TANORANKIVULIFOGLALKOZAS];


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


GO
ALTER TABLE [dbo].[T_TANTARGY]
    ADD [C_MEGJEGYZES]     NVARCHAR (500) NULL,
        [C_MUFAJTANSZAKID] INT            DEFAULT ((7815)) NOT NULL,
        [C_SORSZAM]        INT            DEFAULT ((1000)) NOT NULL;


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


GO
ALTER TABLE [dbo].[T_TANULO] ALTER COLUMN [C_SNILETSZAMSULY] INT NOT NULL;


GO
ALTER TABLE [dbo].[T_TANULO]
    ADD [C_TANTERVIJELLEMZOID] INT NULL;


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


GO
ALTER TABLE [dbo].[T_TANULOTANUGYIADATOK]
    ADD [C_TANTERVIJELLEMZOID] INT NULL;


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


GO
ALTER TABLE [dbo].[T_TEREM]
    ADD [C_MEGJEGYZES] NVARCHAR (500) NULL;


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


GO
CREATE TABLE [dbo].[T_MUFAJTANSZAKTIPUS] (
    [ID]                   INT      NOT NULL,
    [C_ALINTEZMENYID]      INT      NOT NULL,
    [C_ALTANEVID]          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,
    [ELOZOTANEVIREKORDIDA] INT      NULL,
    [NNID]                 INT      NULL,
    CONSTRAINT [PK_MufajTanszakTipus] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


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


GO
CREATE TABLE [dbo].[T_TANTERVIJELLEMZOTIPUS] (
    [ID]                   INT      NOT NULL,
    [C_ALINTEZMENYID]      INT      NOT NULL,
    [C_ALTANEVID]          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,
    [ELOZOTANEVIREKORDIDA] INT      NULL,
    [NNID]                 INT      NULL,
    CONSTRAINT [PK_TanterviJellemzoTipus] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


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


GO
ALTER TABLE [dbo].[T_TANULO]
    ADD DEFAULT ((1)) FOR [C_SNILETSZAMSULY];


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_MUFAJTANSZAKTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_MufajTanszakTipus_Id_AlintezmenyId_AltanevId_REF_DictionaryItemBase] FOREIGN KEY ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_DICTIONARYITEMBASE] ([ID], [C_INTEZMENYID], [C_TANEVID]);


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


GO
ALTER TABLE [dbo].[T_MUFAJTANSZAKTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_MufajTanszakTipus_AlIntezmenyId_REF_Intezmeny] FOREIGN KEY ([C_ALINTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_MUFAJTANSZAKTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_MufajTanszakTipus_AlTanevId_REF_Tanev] FOREIGN KEY ([C_ALTANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANTERVIJELLEMZOTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_TanterviJellemzoTipus_Id_AlintezmenyId_AltanevId_REF_DictionaryItemBase] FOREIGN KEY ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_DICTIONARYITEMBASE] ([ID], [C_INTEZMENYID], [C_TANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANTERVIJELLEMZOTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_TanterviJellemzoTipus_AlIntezmenyId_REF_Intezmeny] FOREIGN KEY ([C_ALINTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANTERVIJELLEMZOTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_TanterviJellemzoTipus_AlTanevId_REF_Tanev] FOREIGN KEY ([C_ALTANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANTARGY] WITH NOCHECK
    ADD CONSTRAINT [FK_Tantargy_MufajTanszakId_IntezmenyId_TanevId_REF_MufajTanszakTipus] FOREIGN KEY ([C_MUFAJTANSZAKID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_MUFAJTANSZAKTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_Tanulo_TanterviJellemzoId_AlintezmenyId_AltanevId_REF_TanterviJellemzoTipus] FOREIGN KEY ([C_TANTERVIJELLEMZOID], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_TANTERVIJELLEMZOTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULOTANUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_TanuloTanugyiAdatok_TanterviJellemzoId_IntezmenyId_TanevId_REF_TanterviJellemzoTipus] FOREIGN KEY ([C_TANTERVIJELLEMZOID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_TANTERVIJELLEMZOTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);





GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[ID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord egyedi azonosítója, generált IDENTITY(1, 1) (kivéve altáblák esetén, ahol a főtábla ID-ját kapja)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'ID';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[C_ALINTEZMENYID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Az intézmény ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'C_ALINTEZMENYID';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[C_ALTANEVID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A tanév ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'C_ALTANEVID';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[TOROLT].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord logikai töröltségét jelző flag', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'TOROLT';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[SERIAL].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Minden C# kódból történő módosítás esetén eggyel nő az értéke. Hogy párhuzamos módosítás esetnán ne íródjanak felül az adatok', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'SERIAL';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[LASTCHANGED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'	A rekord utolsó módosításának időpontja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'LASTCHANGED';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[CREATED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord létrehozásának időpontja ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'CREATED';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[MODIFIER].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot utoljára módosító felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'MODIFIER';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[CREATOR].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot létrehozó felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'CREATOR';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[ELOZOTANEVIREKORDID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDID';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[ELOZOTANEVIREKORDIDA].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja (altábla esetén) ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDIDA';


GO
PRINT N'Creating [dbo].[T_MUFAJTANSZAKTIPUS].[NNID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord régi, Neptun Naplóban lévő ID-ja. (migrációval került be)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_MUFAJTANSZAKTIPUS', @level2type = N'COLUMN', @level2name = N'NNID';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[ID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord egyedi azonosítója, generált IDENTITY(1, 1) (kivéve altáblák esetén, ahol a főtábla ID-ját kapja)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'ID';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[C_ALINTEZMENYID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Az intézmény ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'C_ALINTEZMENYID';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[C_ALTANEVID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A tanév ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'C_ALTANEVID';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[TOROLT].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord logikai töröltségét jelző flag', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'TOROLT';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[SERIAL].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Minden C# kódból történő módosítás esetén eggyel nő az értéke. Hogy párhuzamos módosítás esetnán ne íródjanak felül az adatok', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'SERIAL';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[LASTCHANGED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'	A rekord utolsó módosításának időpontja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'LASTCHANGED';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[CREATED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord létrehozásának időpontja ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'CREATED';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[MODIFIER].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot utoljára módosító felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'MODIFIER';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[CREATOR].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot létrehozó felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'CREATOR';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[ELOZOTANEVIREKORDID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDID';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[ELOZOTANEVIREKORDIDA].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja (altábla esetén) ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDIDA';


GO
PRINT N'Creating [dbo].[T_TANTERVIJELLEMZOTIPUS].[NNID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord régi, Neptun Naplóban lévő ID-ja. (migrációval került be)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_TANTERVIJELLEMZOTIPUS', @level2type = N'COLUMN', @level2name = N'NNID';


GO
PRINT N'Creating [dbo].[T_OSZTALYCSOPORT].[C_TECHNIKAIOSZTALY].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Jelölés, hogy az osztály csak technikai jellegu (például jogviszonyszünetelo tanulóknak)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_OSZTALYCSOPORT', @level2type = N'COLUMN', @level2name = N'C_ISTECHNIKAI';


GO
EXEC dev.uspCreateDictionaryItems @IntezmenyId = NULL, @pTanevNev = NULL



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


GO
ALTER TABLE [dbo].[T_MUFAJTANSZAKTIPUS] WITH CHECK CHECK CONSTRAINT [FK_MufajTanszakTipus_Id_AlintezmenyId_AltanevId_REF_DictionaryItemBase];

ALTER TABLE [dbo].[T_MUFAJTANSZAKTIPUS] WITH CHECK CHECK CONSTRAINT [FK_MufajTanszakTipus_AlIntezmenyId_REF_Intezmeny];

ALTER TABLE [dbo].[T_MUFAJTANSZAKTIPUS] WITH CHECK CHECK CONSTRAINT [FK_MufajTanszakTipus_AlTanevId_REF_Tanev];

ALTER TABLE [dbo].[T_TANTERVIJELLEMZOTIPUS] WITH CHECK CHECK CONSTRAINT [FK_TanterviJellemzoTipus_Id_AlintezmenyId_AltanevId_REF_DictionaryItemBase];

ALTER TABLE [dbo].[T_TANTERVIJELLEMZOTIPUS] WITH CHECK CHECK CONSTRAINT [FK_TanterviJellemzoTipus_AlIntezmenyId_REF_Intezmeny];

ALTER TABLE [dbo].[T_TANTERVIJELLEMZOTIPUS] WITH CHECK CHECK CONSTRAINT [FK_TanterviJellemzoTipus_AlTanevId_REF_Tanev];

ALTER TABLE [dbo].[T_TANTARGY] WITH CHECK CHECK CONSTRAINT [FK_Tantargy_MufajTanszakId_IntezmenyId_TanevId_REF_MufajTanszakTipus];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_Tanulo_TanterviJellemzoId_AlintezmenyId_AltanevId_REF_TanterviJellemzoTipus];

ALTER TABLE [dbo].[T_TANULOTANUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_TanuloTanugyiAdatok_TanterviJellemzoId_IntezmenyId_TanevId_REF_TanterviJellemzoTipus];


GO
PRINT N'Update complete.';

GO
EXEC dev.uspCreateSchemaViews 'T_MUFAJTANSZAKTIPUS, T_TANTERVIJELLEMZOTIPUS ,T_TANULO, T_FELHASZNALO, T_TANTARGY, T_TANULOTANUGYIADATOK, T_OSZTALY, T_OSZTALYCSOPORT, T_ORARENDIORA, T_TANITASIORA, T_TEREM'


GO
EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll


GO

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


GO
