IF EXISTS (select 1 from sys.objects where name = 'FK_Trn_TraEspFuecDetalle_Trn_TraEspReservas' and type='F')
BEGIN
	ALTER TABLE [dbo].[Trn_TraEspFuecDetalle]  
	DROP CONSTRAINT [FK_Trn_TraEspFuecDetalle_Trn_TraEspReservas]   
END
GO
ALTER TABLE [dbo].[Trn_TraEspFuecDetalle]  WITH CHECK ADD  CONSTRAINT [FK_Trn_TraEspFuecDetalle_Trn_TraEspReservas] FOREIGN KEY([TipRes], [Reserva], [IdCiaRes])
REFERENCES [dbo].[Trn_TraEspReservas] ([TipDoc], [Reserva], [IdCia])
GO

ALTER TABLE [dbo].[Trn_TraEspFuecDetalle] CHECK CONSTRAINT [FK_Trn_TraEspFuecDetalle_Trn_TraEspReservas]
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Trn_TraEspFuecCndtores](
	[TipDoc] [varchar](3) NOT NULL CONSTRAINT [DF_Trn_TraEspFuecCndtores_TipDoc]  DEFAULT ('FUE'),
	[Fuec] [int] NOT NULL CONSTRAINT [DF_Trn_TraEspFuecCndtores_Fuec]  DEFAULT ((0)),
	[IdCia] [char](2) NOT NULL CONSTRAINT [DF_Trn_TraEspFuecCndtores_IdCia]  DEFAULT ((1)),
	[Item] [int] NOT NULL,
	[IdConductor] [varchar](16) NOT NULL CONSTRAINT [DF_Trn_TraEspFuecCndtores_IdConductor]  DEFAULT ((0)),
 CONSTRAINT [PK_Trn_TraEspFuecCndtores] PRIMARY KEY CLUSTERED 
(
	[TipDoc] ASC,
	[Fuec] ASC,
	[IdCia] ASC,
	[Item] ASC,
	[IdConductor] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Trn_TraEspFuecCndtores]  WITH CHECK ADD  CONSTRAINT [FK_Trn_TraEspFuecCndtores_TercCndtores] FOREIGN KEY([IdConductor])
REFERENCES [dbo].[TercCndtores] ([IdConductor])
GO

ALTER TABLE [dbo].[Trn_TraEspFuecCndtores] CHECK CONSTRAINT [FK_Trn_TraEspFuecCndtores_TercCndtores]
GO

ALTER TABLE [dbo].[Trn_TraEspFuecCndtores]  WITH CHECK ADD  CONSTRAINT [FK_Trn_TraEspFuecCndtores_Trn_TraEspFuec] FOREIGN KEY([TipDoc], [Fuec], [IdCia])
REFERENCES [dbo].[Trn_TraEspFuec] ([TipDoc], [Fuec], [IdCia])
GO

ALTER TABLE [dbo].[Trn_TraEspFuecCndtores] CHECK CONSTRAINT [FK_Trn_TraEspFuecCndtores_Trn_TraEspFuec]
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TraEspObjContratos](
	[IdObj] [varchar](4) NOT NULL,
	[Objeto] [varchar](500) NOT NULL,
	[Predtminado] [bit] NOT NULL CONSTRAINT [DF_TraEspObjContratos_Predtminado]  DEFAULT ((0)),
	[Inactivo] [bit] NOT NULL CONSTRAINT [DF_TraEspObjContratos_Inactivo]  DEFAULT ((0)),
 CONSTRAINT [PK_TraEspObjContratos] PRIMARY KEY CLUSTERED 
(
	[IdObj] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


INSERT INTO dbo.TraEspObjContratos VALUES
('0','PREDETERMINADO', 0, 1)
GO
ALTER TABLE Trn_TraEspContratoAnexo 
ADD IdObjCOE VARCHAR(4) NOT NULL DEFAULT('0')
GO
ALTER TABLE Trn_TraEspContratoAnexo  WITH CHECK ADD  CONSTRAINT [FK_Trn_TraEspContratoAnexo_TraEspObjContratos] FOREIGN KEY([IdObjCOE])
REFERENCES [dbo].[TraEspObjContratos] ([IdObj])
GO
ALTER TABLE [dbo].[Trn_TraEspContratoAnexo] CHECK CONSTRAINT [FK_Trn_TraEspContratoAnexo_TraEspObjContratos]
GO
