
--Migration_RCCP_20220513_141441.txt
CREATE TABLE [dbo].[AreaGroupTypes] (
    [Id] [uniqueidentifier] NOT NULL,
    [Name] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [SystemCreatedAreaGroup] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.AreaGroupTypes] PRIMARY KEY ([Id])
)
ALTER TABLE [dbo].[FFAreas] ADD [AreaGroupTypeId] [uniqueidentifier]
ALTER TABLE [dbo].[DeviceVerificationDetails] ADD [VerificationStartDateTime] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000'
ALTER TABLE [dbo].[DeviceVerificationDetails] ADD [TuningStartDateTime] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000'
ALTER TABLE [dbo].[DeviceVerificationDetails] ADD [TuningEndDateTime] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000'
ALTER TABLE [dbo].[DeviceVerificationDetails] ADD [CertifiedDateTime] [datetime] NOT NULL DEFAULT '1900-01-01T00:00:00.000'
ALTER TABLE [dbo].[DeviceVerificationDetails] ADD [SourceOfNewVerification] [int] NOT NULL DEFAULT 0
DECLARE @var0 nvarchar(128)
SELECT @var0 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.DeviceVerificationDetails')
AND col_name(parent_object_id, parent_column_id) = 'VerificationSLAStartDate';
IF @var0 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[DeviceVerificationDetails] DROP CONSTRAINT [' + @var0 + ']')
ALTER TABLE [dbo].[DeviceVerificationDetails] DROP COLUMN [VerificationSLAStartDate]
DECLARE @var1 nvarchar(128)
SELECT @var1 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.DeviceVerificationDetails')
AND col_name(parent_object_id, parent_column_id) = 'TuningSLAStartDate';
IF @var1 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[DeviceVerificationDetails] DROP CONSTRAINT [' + @var1 + ']')
ALTER TABLE [dbo].[DeviceVerificationDetails] DROP COLUMN [TuningSLAStartDate]
DECLARE @var2 nvarchar(128)
SELECT @var2 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.DeviceVerificationDetails')
AND col_name(parent_object_id, parent_column_id) = 'TuningSLAEndDate';
IF @var2 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[DeviceVerificationDetails] DROP CONSTRAINT [' + @var2 + ']')
ALTER TABLE [dbo].[DeviceVerificationDetails] DROP COLUMN [TuningSLAEndDate]
DECLARE @var3 nvarchar(128)
SELECT @var3 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.DeviceVerificationDetails')
AND col_name(parent_object_id, parent_column_id) = 'LastCertifiedDate';
IF @var3 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[DeviceVerificationDetails] DROP CONSTRAINT [' + @var3 + ']')
ALTER TABLE [dbo].[DeviceVerificationDetails] DROP COLUMN [LastCertifiedDate]
DECLARE @var4 nvarchar(128)
SELECT @var4 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.DeviceVerificationDetails')
AND col_name(parent_object_id, parent_column_id) = 'SourceOfNew';
IF @var4 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[DeviceVerificationDetails] DROP CONSTRAINT [' + @var4 + ']')
ALTER TABLE [dbo].[DeviceVerificationDetails] DROP COLUMN [SourceOfNew]
