﻿/* Bednář Libor    2025-01-09 00:10:44 */

declare @fulldbname sysname
set @fulldbname='lcs.struktura_povrchu_22.poznamka'

if not exists (select * from lcs.noris_attributes where cislo_tridy = 22411 and dbname = @fulldbname)
 and exists(select * from lcs.noris_classes where cislo_tridy=22411)
AND lcs.nf_is_archive() <> 'A'
begin
insert into lcs.noris_attributes (cislo_tridy, dbname, typ, poradi, expression, editacni_styl, replikovat, zakaz_hz, is_nazev, is_refer, nutnost_zadani, zakazat_def)
values (
22411,
@fulldbname,
'varchar',
1,
null,
'multilline_poznamka',
'N',
'N',
'N',
'N',
'N',
'N'
)

if exists (select * from syscolumns where id = object_id('lcs.noris_attributes') and name = 'priznak_castka_tuz_mena') 
begin
   declare @cmdptm varchar(2500)
   set @cmdptm = 'update lcs.noris_attributes 
     set priznak_castka_tuz_mena=''N''
     where cislo_tridy = 22411 and  dbname = ''' + @fulldbname + ''''
   exec(@cmdptm)
end

if exists (select * from syscolumns where id = object_id('lcs.noris_attributes') and name = 'skryty_udaj') 
begin
declare @cmdsu varchar(2500)
set @cmdsu = 'update lcs.noris_attributes 
   set skryty_udaj = ''N''
   where cislo_tridy = 22411 and dbname = ''' + @fulldbname + ''''
exec (@cmdsu)
end
if exists (select * from syscolumns where id = object_id('lcs.noris_attributes') and name = 'agregacni_funkce_browse') 
begin
declare @cmdsshl varchar(2500)
set @cmdsshl = 'update lcs.noris_attributes 
   set agregacni_funkce_browse = ''FIRST''
   where cislo_tridy = 22411 and dbname = ''' + @fulldbname + '''
   and agregacni_funkce_browse is null'
exec (@cmdsshl)
end
if exists (select * from syscolumns where id = object_id('lcs.noris_attributes') and name = 'mask_value_change') 
begin
declare @cmdsmvc varchar(2500)
set @cmdsmvc = 'update lcs.noris_attributes 
   set mask_value_change = ''N''
   where cislo_tridy = 22411 and dbname = ''' + @fulldbname + ''''
exec (@cmdsmvc)
end

if exists (select * from syscolumns where id = object_id('lcs.noris_attributes') and name = 'reprezentuje_plny_nazev') 
begin
declare @cmdsu1 varchar(2500)
set @cmdsu1 = 'update lcs.noris_attributes 
   set reprezentuje_plny_nazev = ''N''
   where cislo_tridy = 22411
   and dbname = ''' + @fulldbname + ''''
exec (@cmdsu1)
end
if exists (select * from syscolumns where id = object_id('lcs.noris_attributes') and name = 'index_fullsearch_attr') 
exec ('
   update lcs.noris_attributes 
   set index_fullsearch_attr=''A''
   where cislo_tridy = 22411 and dbname = ''' + @fulldbname + '''
')

if exists (select * from sys.columns where object_id = object_id('lcs.noris_attributes') and name = 'symbolic_name') 
exec ('
   update lcs.noris_attributes 
   set symbolic_name = null
   where cislo_tridy = 22411 and dbname = ''' + @fulldbname + ''';
');

insert into lcs.repository_translate (cislo,cislo_tridy,langid,nazev,zkratka) 
select cislo_atributu,56, 'CZ','Poznámka',null from lcs.noris_attributes where cislo_tridy=22411 and dbname=@fulldbname
union
select cislo_atributu,56, isnull ((select langid from lcs.repository_languages where isdefault = 'A'), 'CZ'),'Poznámka',null from lcs.noris_attributes where cislo_tridy=22411 and dbname=@fulldbname and not exists (select * from lcs.repository_translate where cislo = cislo_atributu and cislo_tridy = 56)
end

GO
/* Bednář Libor    2025-01-09 00:11:45 */

if not exists (select * from sys.columns c where c.object_id = object_id('lcs.struktura_povrchu_22') and c.name = 'poznamka') 
and exists (select * from sys.objects where object_id=object_id('lcs.struktura_povrchu_22'))
BEGIN
ALTER TABLE lcs.struktura_povrchu_22
 ADD
	[poznamka] varchar(max)    NULL 
END
GO
