CREATE TABLE [dbo].[policies_replaced_risks_situations]
(
[prlrs_lot_id] [int] NOT NULL,
[prlrs_source_risk_situation_id] [int] NOT NULL,
[prlrs_cancel_risk_situation_id] [int] NULL,
[prlrs_new_risk_situation_id] [int] NULL,
[prlrs_transaction_succeded] [bit] NULL,
[prlrs_crystal_error_code] [dbo].[ais_code_long] NULL,
[prlrs_error_description] [nvarchar] (2000) COLLATE French_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[policies_replaced_risks_situations] ADD CONSTRAINT [PK_policies_replaced_risks_situations] PRIMARY KEY CLUSTERED  ([prlrs_lot_id], [prlrs_source_risk_situation_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[policies_replaced_risks_situations] ADD CONSTRAINT [FK_policies_replaced_risks_situations_crystal_errors_codes] FOREIGN KEY ([prlrs_crystal_error_code]) REFERENCES [dbo].[crystal_errors_codes] ([cec_crystal_error_code])
GO
ALTER TABLE [dbo].[policies_replaced_risks_situations] ADD CONSTRAINT [FK_policies_replaced_risks_situations_policies_replaced_lots] FOREIGN KEY ([prlrs_lot_id]) REFERENCES [dbo].[policies_replaced_lots] ([prl_lot_id])
GO
ALTER TABLE [dbo].[policies_replaced_risks_situations] ADD CONSTRAINT [FK_policies_replaced_risks_situations_ris_risks_situations] FOREIGN KEY ([prlrs_source_risk_situation_id]) REFERENCES [dbo].[ris_risks_situations] ([riss_risk_situation_id])
GO
ALTER TABLE [dbo].[policies_replaced_risks_situations] ADD CONSTRAINT [FK_policies_replaced_risks_situations_ris_risks_situations1] FOREIGN KEY ([prlrs_cancel_risk_situation_id]) REFERENCES [dbo].[ris_risks_situations] ([riss_risk_situation_id])
GO
ALTER TABLE [dbo].[policies_replaced_risks_situations] ADD CONSTRAINT [FK_policies_replaced_risks_situations_ris_risks_situations2] FOREIGN KEY ([prlrs_new_risk_situation_id]) REFERENCES [dbo].[ris_risks_situations] ([riss_risk_situation_id])
GO
