I'm currently working in a .net app that uses a script to refresh all the database when you checkout to a different git branch. The case is when this script 'refreshes' and cleans all the old test data from that branch also execute all the migration files from a folder named 'migrations'. So i'm trying to create a migration to insert some specific values in some tables using idempotence. This migration file must be like the others inside the 'migrations' folder (idempotent) in order to be executed every time the script is executed, so that it does not duplicate the data, keep the structure and be executed multiple times and leave the database in the same state.
The inserts are:
USE [$defaultDB]
GO
INSERT INTO [dbo].[Catalog]
([name]
,[description]
,[createdBy]
,[createdOn]
,[createdIn]
,[modifiedBy]
,[modifiedOn]
,[modifiedIn]
,[isActive]
,[catalogTypeID])
VALUES
('PolicyClasificationID',
'Id de clasificación de póliza',
2,
2022-01-20 13:43:09.687,
'127.0.0.1',
2,
2022-01-20 13:43:09.687,
'127.0.0.1',
1,
1,
)
GO
INSERT INTO [dbo].[CatalogItem]
([catalogID]
,[catalogFlavorID]
,[parentCatalogItemID]
,[name]
,[displayLabel]
,[description]
,[catalogValue]
,[sequence]
,[createdBy]
,[createdOn]
,[createdIn]
,[modifiedBy]
,[modifiedOn]
,[isActive]
,[parentCatalogID]
,[parentCatalogValueID])
VALUES
(271, 1, NULL, 'Fidem', 'FIDEM', NULL, 1, 1, 2, '2022-01-20 12:41:12.203', '127.0.0.1', 2, '2022-01-20 12:41:12.203', 1, NULL, NULL)
(271, 1, NULL, 'Bac', 'BAC', NULL, 2, 2, 2, '2022-01-21 12:41:12.203', '127.0.0.1', 2, '2022-01-21 12:41:12.203', 1, NULL, NULL)
GO
INSERT INTO [dbo].[CompanyComponentFlavor]
([companyID]
,[componentID]
,[subComponentID]
,[flavorID])
VALUES
(3,
7,
271,
1)
END
Any help would be appreciated.