UPDATE TBDD_MODULES SET DB_VERSION = '1.1.0.3' WHERE SHORT_NAME = 'SIG_ENV_CR'
GO
CREATE TABLE [dbo].[TBSIG_EMAIL_TEMPLATE](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[NAME] [nvarchar](64) NULL,
	[BODY] [nvarchar](max) NULL,
	[SUBJECT] [nvarchar](512) NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
	[CHANGED_WHEN] [datetime] NULL,
	[LANG_CODE] [varchar](5) NOT NULL,
 CONSTRAINT [PK_TBSIG_EMAIL_TEMPLATE] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[TBSIG_EMAIL_TEMPLATE] ADD  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO

ALTER TABLE [dbo].[TBSIG_EMAIL_TEMPLATE] ADD  DEFAULT ('de-DE') FOR [LANG_CODE]
GO



CREATE TRIGGER [dbo].[TBSIG_EMAIL_TEMPLATE_AFT_UPD] ON [dbo].[TBSIG_EMAIL_TEMPLATE]
FOR UPDATE
AS
	UPDATE TBSIG_EMAIL_TEMPLATE SET CHANGED_WHEN = GETDATE() FROM INSERTED WHERE TBSIG_EMAIL_TEMPLATE.GUID = INSERTED.GUID
GO
ALTER TABLE [dbo].[TBSIG_CONFIG] ADD [ADDED_WHEN] DATETIME NOT NULL DEFAULT GETDATE();
ALTER TABLE [dbo].[TBSIG_CONFIG] ADD [CHANGED_WHEN] DATETIME ;
ALTER TABLE [dbo].[TBSIG_CONFIG] ADD [GUID] TINYINT NOT NULL DEFAULT 1;
GO
CREATE TRIGGER [dbo].[TBSIG_CONFIG_AFT_UPD] ON [dbo].[TBSIG_CONFIG]
FOR UPDATE
AS
	UPDATE TBSIG_CONFIG SET CHANGED_WHEN = GETDATE() FROM INSERTED WHERE TBSIG_CONFIG.GUID = 1
GO