


--Creacion Tabla
if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='gen_firmaContacto')
EXEC _ini_creartabla 'gen_firmaContacto', 1
GO

print('-creacion tabla gen_firmaContacto-')

if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='gen_firma')
EXEC _ini_creartabla 'gen_firma', 1
GO



if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='gen_firma_aux')
create table [gen_firma_aux] (
uid varchar (500)
,[firma] varchar (300)
,[firma_codigo] varchar (100)

)
GO


if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='gen_firmaContacto_aux')
create table [gen_firmaContacto_aux] (
uid varchar (500)
,[firmaContacto] varchar (300)
,[firmaContacto_codigo] varchar (100)
,[firmaContacto_contacto_contacto] varchar (300)
,[firmaContacto_contacto_contacto_codigo] varchar (100)

)
GO



print('-creacion tabla gen_firma-')

--Creacion Columna
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='gen_firmaContacto' and column_name = 'id_contacto' )
begin
alter table [gen_firmaContacto] add [id_contacto] int not null default 0
end

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='gen_firmaContacto' and column_name = 'codigoacceso' )
begin
alter table [gen_firmaContacto] add [codigoacceso] varchar(100) not null default ''
end

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='gen_firmaContacto' and column_name = 'archivobinario' )
begin
alter table [gen_firmaContacto] add [archivobinario] image  null 
end

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='gen_firma' and column_name = 'fecha_fh' )
begin
alter table [gen_firmaContacto] add [fecha_fh] smalldatetime not null default 01/01/1900
end



if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='gen_firma' and column_name = 'tabla' )
begin
alter table [gen_firma] add [tabla]  varchar(100) not null default ''
end

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='gen_firma' and column_name = 'idobjeto' )
begin
alter table [gen_firma] add [idobjeto] int not null default 0
end

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='gen_firma' and column_name = 'archivobinario' )
begin
alter table [gen_firma] add [archivobinario] image  null 
end

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='gen_firma' and column_name = 'fecha_fh' )
begin
alter table [gen_firma] add [fecha_fh] smalldatetime not null default 01/01/1900
end

print('-creacion columnas gen_firma, gen_firmaContacto-')