if not exists (select 1 from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'equ_analisisFalla')
begin
	exec [_ini_creartabla] 'equ_analisisFalla', 1
end
go

if not exists (select 1 from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'equ_analisisFalla' and COLUMN_NAME = 'id_catalogo.equipo')
begin
	ALTER TABLE [equ_analisisFalla] ADD [id_catalogo.equipo] INT NOT NULL DEFAULT 0
	FOREIGN KEY ([id_catalogo.equipo]) REFERENCES [cat_catalogo.equipo](id)
end
go

if not exists (select 1 from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'equ_analisisFalla' and COLUMN_NAME = 'id_falla')
begin
	ALTER TABLE [equ_analisisFalla] ADD [id_falla] INT NOT NULL DEFAULT 0
	FOREIGN KEY ([id_falla]) REFERENCES [equ_falla](id)
end
go

if not exists (select 1 from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'equ_analisisFalla' and COLUMN_NAME = 'id_falla_causa')
begin
	ALTER TABLE [equ_analisisFalla] ADD [id_falla_causa] INT NOT NULL DEFAULT 0
	FOREIGN KEY ([id_falla_causa]) REFERENCES [equ_falla](id)
end
go

if not exists (select 1 from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'equ_analisisFalla' and COLUMN_NAME = 'id_falla_efecto')
begin
	ALTER TABLE [equ_analisisFalla] ADD [id_falla_efecto] INT NOT NULL DEFAULT 0
	FOREIGN KEY ([id_falla_efecto]) REFERENCES [equ_falla](id)
end
go

if not exists (select 1 from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'equ_analisisFalla' and COLUMN_NAME = 'id_falla_solucion')
begin
	ALTER TABLE [equ_analisisFalla] ADD [id_falla_solucion] INT NOT NULL DEFAULT 0
	FOREIGN KEY ([id_falla_solucion]) REFERENCES [equ_falla](id)
end
go
