/*
   20 September 202113:14:36
   User: 
   Server: (local)
   Database: SISIMPU
   Application: 
*/

/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE [Transaction].Synchronizations
	DROP CONSTRAINT DF_Synchronizations_SynchronizationStatus
GO
CREATE TABLE [Transaction].Tmp_Synchronizations
	(
	SynchronizationId int NOT NULL IDENTITY (1, 1),
	SynchronizationRegulationId int NULL,
	SynchronizationRdkId int NULL,
	SynchronizationRequestNDNomor varchar(100) NULL,
	SynchronizationRequestNDDate date NULL,
	SynchronizationRequestNDDocumentId int NULL,
	SynchronizationRequestDate datetime NULL,
	SynchronizationKementrianRequestNDNomor varchar(100) NULL,
	SynchronizationKementrianRequestNDDate date NULL,
	SynchronizationKementrianRequestNDDocumentId int NULL,
	SynchronizationKementrianRequestDate datetime NULL,
	SynchronizationResponseNDNomor varchar(100) NULL,
	SynchronizationResponseNDDate date NULL,
	SynchronizationResponseNDDocumentId int NULL,
	SynchronizationResponseDate datetime NULL,
	SynchronizationCreateBy int NULL,
	SynchronizationCreateDate datetime NULL,
	SynchronizationUpdateBy int NULL,
	SynchronizationUpdateDate datetime NULL,
	SynchronizationStatus bit NOT NULL
	)  ON [PRIMARY]
GO
ALTER TABLE [Transaction].Tmp_Synchronizations SET (LOCK_ESCALATION = TABLE)
GO
ALTER TABLE [Transaction].Tmp_Synchronizations ADD CONSTRAINT
	DF_Synchronizations_SynchronizationStatus DEFAULT ((0)) FOR SynchronizationStatus
GO
SET IDENTITY_INSERT [Transaction].Tmp_Synchronizations ON
GO
IF EXISTS(SELECT * FROM [Transaction].Synchronizations)
	 EXEC('INSERT INTO [Transaction].Tmp_Synchronizations (SynchronizationId, SynchronizationRegulationId, SynchronizationRdkId, SynchronizationRequestNDNomor, SynchronizationRequestNDDate, SynchronizationRequestNDDocumentId, SynchronizationRequestDate, SynchronizationResponseNDNomor, SynchronizationResponseNDDate, SynchronizationResponseNDDocumentId, SynchronizationResponseDate, SynchronizationCreateBy, SynchronizationCreateDate, SynchronizationUpdateBy, SynchronizationUpdateDate, SynchronizationStatus)
		SELECT SynchronizationId, SynchronizationRegulationId, SynchronizationRdkId, SynchronizationRequestNDNomor, SynchronizationRequestNDDate, SynchronizationRequestNDDocumentId, SynchronizationRequestDate, SynchronizationResponseNDNomor, SynchronizationResponseNDDate, SynchronizationResponseNDDocumentId, SynchronizationResponseDate, SynchronizationCreateBy, SynchronizationCreateDate, SynchronizationUpdateBy, SynchronizationUpdateDate, SynchronizationStatus FROM [Transaction].Synchronizations WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT [Transaction].Tmp_Synchronizations OFF
GO
DROP TABLE [Transaction].Synchronizations
GO
EXECUTE sp_rename N'[Transaction].Tmp_Synchronizations', N'Synchronizations', 'OBJECT' 
GO
ALTER TABLE [Transaction].Synchronizations ADD CONSTRAINT
	PK_Synchronizations PRIMARY KEY CLUSTERED 
	(
	SynchronizationId
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
COMMIT
