------ 1. Remove Current transition entries -----------------
truncate table tbLocalisationDataTransition 
go

------ 2. Insert updated default entries -----------------

BEGIN TRANSACTION

COMMIT TRANSACTION
go

------  Insert updated default entries  for zh-CN -----------------

BEGIN TRANSACTION

COMMIT TRANSACTION
go

------  Insert updated default entries  for nl -----------------

BEGIN TRANSACTION

COMMIT TRANSACTION
go

------  Insert updated default entries  for de -----------------

BEGIN TRANSACTION

COMMIT TRANSACTION
go

------  Insert updated default entries  for en-US -----------------

BEGIN TRANSACTION

COMMIT TRANSACTION
go

------ Backup current localisation settings ----------------- 
IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'bak') 
    BEGIN 
        EXEC( 'CREATE SCHEMA bak' ); 
    END
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[bak].[tbLocalisationDataBackupPreDeploy_20191226]') AND type in (N'U'))
	DROP TABLE [bak].[tbLocalisationDataBackupPreDeploy_20191226]
go
select Section, ResourceType, ResourceKey, CultureCode, ResourceValue, SpecialType, UserEditable into bak.tbLocalisationDataBackupPreDeploy_20191226 from tbLocalisationData
go
------ Insert values from transition table ----------------- 
Insert Into tbLocalisationData(Section, ResourceType, ResourceKey, CultureCode, ResourceValue, SpecialType, UserEditable) 
Select Section, ResourceType, ResourceKey, CultureCode, ResourceValue, SpecialType, 1 From tbLocalisationDataTransition 
Where Not exists ( 
	Select * from tbLocalisationData Where  
		tbLocalisationData.Section = tbLocalisationDataTransition.Section AND 
		tbLocalisationData.ResourceType = tbLocalisationDataTransition.ResourceType AND 
		tbLocalisationData.ResourceKey = tbLocalisationDataTransition.ResourceKey AND 
		tbLocalisationData.CultureCode = tbLocalisationDataTransition.CultureCode) 
go

