diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj
index ba8e0e9b7..04dd70b5b 100644
--- a/src/Sql/Sql.sqlproj
+++ b/src/Sql/Sql.sqlproj
@@ -216,5 +216,7 @@
+
+
\ No newline at end of file
diff --git a/src/Sql/dbo/Tables/Event.sql b/src/Sql/dbo/Tables/Event.sql
index 7a4a2aeb5..b5448dee8 100644
--- a/src/Sql/dbo/Tables/Event.sql
+++ b/src/Sql/dbo/Tables/Event.sql
@@ -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);
+
diff --git a/util/Setup/DbScripts/2017-12-12_00_Events.sql b/util/Setup/DbScripts/2017-12-12_00_Events.sql
new file mode 100644
index 000000000..568466360
--- /dev/null
+++ b/util/Setup/DbScripts/2017-12-12_00_Events.sql
@@ -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
diff --git a/util/Setup/Setup.csproj b/util/Setup/Setup.csproj
index bd14b4f47..b9474579b 100644
--- a/util/Setup/Setup.csproj
+++ b/util/Setup/Setup.csproj
@@ -8,6 +8,7 @@
+