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

SET NUMERIC_ROUNDABORT OFF;



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


GO
ALTER TABLE [dbo].[T_DASHBOARDUZENET]
    ADD [C_DASHBOARDUZENETKATEGORIAID] INT NOT NULL;


GO
PRINT N'Creating [dbo].[T_DASHBOARDUZENET].[I_T_4028858_4028857]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028858_4028857]
    ON [dbo].[T_DASHBOARDUZENET]([C_DASHBOARDUZENETKATEGORIAID] ASC);


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


GO
ALTER TABLE [dbo].[T_DASHBOARDUZENET] WITH NOCHECK
    ADD CONSTRAINT [FK_4028858_4028857] FOREIGN KEY ([C_DASHBOARDUZENETKATEGORIAID]) REFERENCES [dbo].[T_DASHBOARDUZENETKATEGORIA] ([ID]);


GO
PRINT N'Altering [dbo].[T_DASHBOARDUZENET].[C_CIM].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'a Dashboard üzenet cím mezoje', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_DASHBOARDUZENET', @level2type = N'COLUMN', @level2name = N'C_CIM';


GO
PRINT N'Altering [dbo].[T_DASHBOARDUZENET].[C_ERVENYESSEGKEZDETE].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'a Dashboard üzenet ettol az idoponttól látható, ha NULL akkor a kezdetektol', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_DASHBOARDUZENET', @level2type = N'COLUMN', @level2name = N'C_ERVENYESSEGKEZDETE';


GO
PRINT N'Altering [dbo].[T_DASHBOARDUZENET].[C_ERVENYESSEGVEGE].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'a Dashboard üzenet eddig az idopontig lesz látható', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_DASHBOARDUZENET', @level2type = N'COLUMN', @level2name = N'C_ERVENYESSEGVEGE';


GO
PRINT N'Altering [dbo].[T_DASHBOARDUZENET].[C_KIEMELTIDOSZAKVEGE].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'az üzenet eddig az idopontig kiemelten az elso helyen fog szerepelni, ezt követoen a sorrendje helyén', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_DASHBOARDUZENET', @level2type = N'COLUMN', @level2name = N'C_KIEMELTIDOSZAKVEGE';


GO
PRINT N'Altering [dbo].[T_DASHBOARDUZENET].[C_SORREND].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'a Dashboard üzenet sorrendje, hogy kb. hányadikként jelenjen meg a felületen', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_DASHBOARDUZENET', @level2type = N'COLUMN', @level2name = N'C_SORREND';


GO
PRINT N'Altering [dbo].[T_DASHBOARDUZENET].[C_TARTALOM].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'a Dashboard üzenet tartalma', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_DASHBOARDUZENET', @level2type = N'COLUMN', @level2name = N'C_TARTALOM';


GO
PRINT N'Creating [dbo].[T_DASHBOARDUZENET].[C_DASHBOARDUZENETKATEGORIAID].[MS_Description]...';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'meghatározza a dashboard üzenet fontosságát', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_DASHBOARDUZENET', @level2type = N'COLUMN', @level2name = N'C_DASHBOARDUZENETKATEGORIAID';


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


GO
ALTER TABLE [dbo].[T_DASHBOARDUZENET] WITH CHECK CHECK CONSTRAINT [FK_4028858_4028857];


GO
PRINT N'Update complete.';


GO
--------------------

PRINT '--- intézményi view-k (dbo táblákkal megegyező nevű és a tábla_OSSZES nevűek) frissítése ---'

DECLARE  @viewname nvarchar(100), @pureview nvarchar(100)

DECLARE semaviewk CURSOR LOCAL FOR 
  SELECT '['+TABLE_SCHEMA + '].[' + TABLE_NAME + ']', TABLE_NAME
  FROM INFORMATION_SCHEMA.TABLES
  WHERE TABLE_TYPE = 'VIEW' and TABLE_SCHEMA LIKE 'KR[_]%[_]Schema'
  AND TABLE_NAME in ('T_DASHBOARDUZENET', 'T_DASHBOARDUZENET_OSSZES' ) -- ha csak néhány VIEW frissült, akkor a gyorsabb futásért ide fel lehet sorolni
  ORDER BY TABLE_SCHEMA, TABLE_NAME

OPEN semaviewk
FETCH NEXT FROM semaviewk INTO @viewname, @pureview

WHILE @@FETCH_STATUS = 0 BEGIN
    PRINT @viewname
    EXEC sp_refreshview @viewname

    FETCH NEXT FROM semaviewk INTO @viewname, @pureview
END             

CLOSE semaviewk
DEALLOCATE semaviewk
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