
--Migration_RCCP_20211208_111140.txt
CREATE TABLE [dbo].[PublicHolidayConfigurations] (
    [Id] [bigint] NOT NULL IDENTITY,
    [PublicHolidayName] [nvarchar](max),
    [PublicHolidayDateTime] [datetime] NOT NULL,
    [CreationDateTime] [datetime] NOT NULL,
    [LastUpdatedDateTime] [datetime] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.PublicHolidayConfigurations] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[PublicHolidayLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [PublicHolidayId] [bigint] NOT NULL,
    [GranularityType] [int] NOT NULL,
    [GranularityId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.PublicHolidayLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[WorkspaceAttendees] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [UserId] [bigint] NOT NULL,
    [IsHost] [bit] NOT NULL,
    [WorkspaceUserType] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [DeletedDateTime] [datetime] NOT NULL,
    [BookingId] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.WorkspaceAttendees] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[WorkspaceGuests] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Name] [nvarchar](max),
    [Email] [nvarchar](max),
    [ServerGuid] [uniqueidentifier] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [CreatedBy] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [DeletedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.WorkspaceGuests] PRIMARY KEY ([Id])
)
ALTER TABLE [dbo].[BookingSchedules] ADD [BookingStatus] [int] NOT NULL DEFAULT 0
CREATE INDEX [IX_CompanyId] ON [dbo].[PublicHolidayConfigurations]([CompanyId])
CREATE INDEX [IX_PublicHolidayId] ON [dbo].[PublicHolidayLinks]([PublicHolidayId])
CREATE INDEX [IX_BookingId] ON [dbo].[WorkspaceAttendees]([BookingId])
ALTER TABLE [dbo].[PublicHolidayConfigurations] ADD CONSTRAINT [FK_dbo.PublicHolidayConfigurations_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID])
ALTER TABLE [dbo].[PublicHolidayLinks] ADD CONSTRAINT [FK_dbo.PublicHolidayLinks_dbo.PublicHolidayConfigurations_PublicHolidayId] FOREIGN KEY ([PublicHolidayId]) REFERENCES [dbo].[PublicHolidayConfigurations] ([Id])
ALTER TABLE [dbo].[WorkspaceAttendees] ADD CONSTRAINT [FK_dbo.WorkspaceAttendees_dbo.BookingSchedules_BookingId] FOREIGN KEY ([BookingId]) REFERENCES [dbo].[BookingSchedules] ([ID]) ON DELETE CASCADE
