/***************************************************************************
* Copyright (C) 2025 DataKings / Kers IT All rights reserved.
'***************************************************************************/

if not exists(select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'CSEasyWMDefs' and COLUMN_NAME = 'Connection')
begin
	alter table [dbo].[CSEasyWMDefs]
		add [Connection] nvarchar(30) NOT NULL default('Synergy')
end
go

if not exists(select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'CSEasyWMDefLists' and COLUMN_NAME = 'Connection')
begin
	alter table [dbo].[CSEasyWMDefLists]
		add [Connection] nvarchar(30) NOT NULL default('Synergy')
end
go

if exists(select * from DDTests where TableName = 'CSEasyWMDefs' and FieldName = 'Status' and DatabaseChar = 'H')
begin
	delete from DDTests where TableName = 'CSEasyWMDefs' and FieldName = 'Status' and DatabaseChar = 'H'
	insert into DDTests(DatabaseChar, Tablename, FieldName, DisplayChar, Description, TermId, Options, SeqNr) values('A', 'CSEasyWMDefs', 'Status', 'A', 'Archived', 305, '', 3)
end
go

if exists(select * from CSEasyWMDefs where Status = 'H')
begin
	update CSEasyWMDefs
	set Status = 'A'
	where Status = 'H'
end
go

delete from DDTests where TableName = 'CSEasyWMDefFixedAttachments' and FieldName = 'AttachmentType' and DatabaseChar = 'O'
go


update CSEasyWMIntegrationPages
set ShowAsButtons = 0
where ShowAsButtons = 1
go


if not exists(select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'CSEasyWMIntegrationPages' and COLUMN_NAME = 'Active')
begin
	alter table [dbo].[CSEasyWMIntegrationPages]
		add [Active] tinyint NOT NULL default(1)
end
go