1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

event index and setup script

This commit is contained in:
Kyle Spearrin 2017-12-12 14:39:56 -05:00
parent ce1680a009
commit 5c91949f2d
4 changed files with 74 additions and 0 deletions

View File

@ -216,5 +216,7 @@
<Build Include="dbo\Stored Procedures\Cipher_DeleteByUserId.sql" />
<Build Include="dbo\Stored Procedures\User_BumpAccountRevisionDateByCollectionId.sql" />
<Build Include="dbo\Stored Procedures\User_BumpAccountRevisionDateByCipherId.sql" />
<Build Include="dbo\Tables\Event.sql" />
<Build Include="dbo\Stored Procedures\Event_Create.sql" />
</ItemGroup>
</Project>

View File

@ -11,3 +11,8 @@
CONSTRAINT [PK_Event] PRIMARY KEY CLUSTERED ([Id] ASC)
);
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Event_Date]
ON [dbo].[Event]([Date] ASC);

View File

@ -0,0 +1,66 @@
IF OBJECT_ID('[dbo].[Event]') IS NULL
BEGIN
CREATE TABLE [dbo].[Event] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[Type] INT NOT NULL,
[UserId] UNIQUEIDENTIFIER NULL,
[OrganizationId] UNIQUEIDENTIFIER NULL,
[CipherId] UNIQUEIDENTIFIER NULL,
[CollectionId] UNIQUEIDENTIFIER NULL,
[GroupId] UNIQUEIDENTIFIER NULL,
[OrganizationUserId] UNIQUEIDENTIFIER NULL,
[Date] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_Event] PRIMARY KEY CLUSTERED ([Id] ASC)
);
CREATE UNIQUE NONCLUSTERED INDEX [IX_Event_Date]
ON [dbo].[Event]([Date] ASC);
END
GO
IF OBJECT_ID('[dbo].[Event_Create]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Event_Create]
END
GO
CREATE PROCEDURE [dbo].[Event_Create]
@Id UNIQUEIDENTIFIER,
@Type INT,
@UserId UNIQUEIDENTIFIER,
@OrganizationId UNIQUEIDENTIFIER,
@CipherId UNIQUEIDENTIFIER,
@CollectionId UNIQUEIDENTIFIER,
@GroupId UNIQUEIDENTIFIER,
@OrganizationUserId UNIQUEIDENTIFIER,
@Date DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [dbo].[Event]
(
[Id],
[Type],
[UserId],
[OrganizationId],
[CipherId],
[CollectionId],
[GroupId],
[OrganizationUserId],
[Date]
)
VALUES
(
@Id,
@Type,
@UserId,
@OrganizationId,
@CipherId,
@CollectionId,
@GroupId,
@OrganizationUserId,
@Date
)
END
GO

View File

@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="DbScripts\2017-12-12_00_Events.sql" />
<EmbeddedResource Include="DbScripts\2017-11-24_00_UpdateProcs.sql" />
<EmbeddedResource Include="DbScripts\2017-11-13_00_IndexTuning.sql" />
<EmbeddedResource Include="DbScripts\2017-11-06_00_FamilyPlanAdjustments.sql" />