
--Migration_RCCP_20251104_180809.txt
CREATE TABLE [dbo].[PlannedImagePlots] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [PlannedFloorplanId] [uniqueidentifier] NOT NULL,
    [PlannedSiteImageId] [uniqueidentifier] NOT NULL,
    [ImageSourcePath] [nvarchar](max),
    [PlotName] [nvarchar](max),
    [PlotCode] [nvarchar](max),
    [PlotPoints] [nvarchar](max),
    [CreatedUtcDateTime] [datetime],
    [LastUpdateUtcDateTime] [datetime],
    CONSTRAINT [PK_dbo.PlannedImagePlots] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[PlannedSiteImages] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [PlannedSiteId] [uniqueidentifier] NOT NULL,
    [FileLocation] [nvarchar](max),
    [Remark] [nvarchar](max),
    [CreatedUtcDateTime] [datetime],
    [LastUpdateUtcDateTime] [datetime],
    CONSTRAINT [PK_dbo.PlannedSiteImages] PRIMARY KEY ([Id])
)
ALTER TABLE [dbo].[PlannedDevicePlots] ADD [DeviceModelName] [nvarchar](max)
ALTER TABLE [dbo].[PlannedDevicePlots] ADD [DeviceModelNumber] [nvarchar](max)
DECLARE @var0 nvarchar(128)
SELECT @var0 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.PredictionJobLists')
AND col_name(parent_object_id, parent_column_id) = 'Status';
IF @var0 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[PredictionJobLists] DROP CONSTRAINT [' + @var0 + ']')
ALTER TABLE [dbo].[PredictionJobLists] ALTER COLUMN [Status] [int] NOT NULL
DECLARE @var1 nvarchar(128)
SELECT @var1 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.PredictionJobLists')
AND col_name(parent_object_id, parent_column_id) = 'EntityType';
IF @var1 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[PredictionJobLists] DROP CONSTRAINT [' + @var1 + ']')
ALTER TABLE [dbo].[PredictionJobLists] ALTER COLUMN [EntityType] [int] NOT NULL
DECLARE @var2 nvarchar(128)
SELECT @var2 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.PredictionJobLists')
AND col_name(parent_object_id, parent_column_id) = 'TimeGranularity';
IF @var2 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[PredictionJobLists] DROP CONSTRAINT [' + @var2 + ']')
ALTER TABLE [dbo].[PredictionJobLists] ALTER COLUMN [TimeGranularity] [int] NOT NULL
DECLARE @var3 nvarchar(128)
SELECT @var3 = name
FROM sys.default_constraints
WHERE parent_object_id = object_id(N'dbo.PredictionJobLists')
AND col_name(parent_object_id, parent_column_id) = 'Mode';
IF @var3 IS NOT NULL
    EXECUTE('ALTER TABLE [dbo].[PredictionJobLists] DROP CONSTRAINT [' + @var3 + ']')
ALTER TABLE [dbo].[PredictionJobLists] ALTER COLUMN [Mode] [int] NOT NULL
