CREATE TABLE [dbo].[policies_replaced_policies_situations]
(
[prls_lot_id] [int] NOT NULL,
[prls_source_policy_situation_id] [int] NOT NULL,
[prls_cancel_policy_situation_id] [int] NULL,
[prls_new_policy_situation_id] [int] NULL,
[prls_start_date] [datetime] NOT NULL,
[prls_end_date] [datetime] NULL,
[prls_transaction_succeded] [bit] NULL,
[prls_crystal_error_code] [dbo].[ais_code_long] NULL,
[prls_error_description] [nvarchar] (2000) COLLATE French_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[policies_replaced_policies_situations] ADD CONSTRAINT [PK_policies_replaced_policies_situations] PRIMARY KEY CLUSTERED  ([prls_lot_id], [prls_source_policy_situation_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[policies_replaced_policies_situations] ADD CONSTRAINT [FK_policies_replaced_policies_situations_crystal_errors_codes] FOREIGN KEY ([prls_crystal_error_code]) REFERENCES [dbo].[crystal_errors_codes] ([cec_crystal_error_code])
GO
ALTER TABLE [dbo].[policies_replaced_policies_situations] ADD CONSTRAINT [FK_policies_replaced_policies_situations_pol_policies_situations] FOREIGN KEY ([prls_source_policy_situation_id]) REFERENCES [dbo].[pol_policies_situations] ([pols_policy_situation_id])
GO
ALTER TABLE [dbo].[policies_replaced_policies_situations] ADD CONSTRAINT [FK_policies_replaced_policies_situations_pol_policies_situations1] FOREIGN KEY ([prls_cancel_policy_situation_id]) REFERENCES [dbo].[pol_policies_situations] ([pols_policy_situation_id])
GO
ALTER TABLE [dbo].[policies_replaced_policies_situations] ADD CONSTRAINT [FK_policies_replaced_policies_situations_pol_policies_situations2] FOREIGN KEY ([prls_new_policy_situation_id]) REFERENCES [dbo].[pol_policies_situations] ([pols_policy_situation_id])
GO
ALTER TABLE [dbo].[policies_replaced_policies_situations] ADD CONSTRAINT [FK_policies_replaced_policies_situations_policies_replaced_lots] FOREIGN KEY ([prls_lot_id]) REFERENCES [dbo].[policies_replaced_lots] ([prl_lot_id])
GO
