diff --git a/src/Core/Models/Table/User.cs b/src/Core/Models/Table/User.cs index 1868d1bc66..13c839ffbd 100644 --- a/src/Core/Models/Table/User.cs +++ b/src/Core/Models/Table/User.cs @@ -32,6 +32,7 @@ namespace Bit.Core.Models.Table public string PrivateKey { get; set; } public bool Premium { get; set; } public DateTime? PremiumExpirationDate { get; set; } + public DateTime? RenewalReminderDate { get; set; } public long? Storage { get; set; } public short? MaxStorageGb { get; set; } public GatewayType? Gateway { get; set; } diff --git a/src/Sql/dbo/Stored Procedures/User_Create.sql b/src/Sql/dbo/Stored Procedures/User_Create.sql index 69f89322d5..292677f6dc 100644 --- a/src/Sql/dbo/Stored Procedures/User_Create.sql +++ b/src/Sql/dbo/Stored Procedures/User_Create.sql @@ -17,6 +17,7 @@ @PrivateKey NVARCHAR(MAX), @Premium BIT, @PremiumExpirationDate DATETIME2(7), + @RenewalReminderDate DATETIME2(7), @Storage BIGINT, @MaxStorageGb SMALLINT, @Gateway TINYINT, @@ -49,6 +50,7 @@ BEGIN [PrivateKey], [Premium], [PremiumExpirationDate], + [RenewalReminderDate], [Storage], [MaxStorageGb], [Gateway], @@ -78,6 +80,7 @@ BEGIN @PrivateKey, @Premium, @PremiumExpirationDate, + @RenewalReminderDate, @Storage, @MaxStorageGb, @Gateway, diff --git a/src/Sql/dbo/Stored Procedures/User_Update.sql b/src/Sql/dbo/Stored Procedures/User_Update.sql index c820a99927..39ad5462eb 100644 --- a/src/Sql/dbo/Stored Procedures/User_Update.sql +++ b/src/Sql/dbo/Stored Procedures/User_Update.sql @@ -17,6 +17,7 @@ @PrivateKey NVARCHAR(MAX), @Premium BIT, @PremiumExpirationDate DATETIME2(7), + @RenewalReminderDate DATETIME2(7), @Storage BIGINT, @MaxStorageGb SMALLINT, @Gateway TINYINT, @@ -49,6 +50,7 @@ BEGIN [PrivateKey] = @PrivateKey, [Premium] = @Premium, [PremiumExpirationDate] = @PremiumExpirationDate, + [RenewalReminderDate] = @RenewalReminderDate, [Storage] = @Storage, [MaxStorageGb] = @MaxStorageGb, [Gateway] = @Gateway, diff --git a/src/Sql/dbo/Tables/User.sql b/src/Sql/dbo/Tables/User.sql index ff2fe03240..f460a23045 100644 --- a/src/Sql/dbo/Tables/User.sql +++ b/src/Sql/dbo/Tables/User.sql @@ -17,6 +17,7 @@ [PrivateKey] VARCHAR (MAX) NULL, [Premium] BIT NOT NULL, [PremiumExpirationDate] DATETIME2 (7) NULL, + [RenewalReminderDate] DATETIME2 (7) NULL, [Storage] BIGINT NULL, [MaxStorageGb] SMALLINT NULL, [Gateway] TINYINT NULL, @@ -33,3 +34,7 @@ GO CREATE UNIQUE NONCLUSTERED INDEX [IX_User_Email] ON [dbo].[User]([Email] ASC); +GO +CREATE UNIQUE NONCLUSTERED INDEX [IX_User_Premium_PremiumExpirationDate_RenewalReminderDate] + ON [dbo].[User]([Premium] ASC, [PremiumExpirationDate] ASC, [RenewalReminderDate] ASC); + diff --git a/util/Setup/DbScripts/2018-06-11_00_WebVaultUpdates.sql b/util/Setup/DbScripts/2018-06-11_00_WebVaultUpdates.sql index 4b32eb4011..7d44bb5e81 100644 --- a/util/Setup/DbScripts/2018-06-11_00_WebVaultUpdates.sql +++ b/util/Setup/DbScripts/2018-06-11_00_WebVaultUpdates.sql @@ -1,4 +1,13 @@ -IF OBJECT_ID('[dbo].[Collection_ReadByUserId]') IS NOT NULL +IF COL_LENGTH('[dbo].[User]', 'RenewalReminderDate') IS NULL +BEGIN + ALTER TABLE + [dbo].[User] + ADD + [RenewalReminderDate] DATETIME2 (7) NULL +END +GO + +IF OBJECT_ID('[dbo].[Collection_ReadByUserId]') IS NOT NULL BEGIN DROP PROCEDURE [dbo].[Collection_ReadByUserId] END @@ -236,3 +245,17 @@ BEGIN EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationId] @OrganizationId END GO + +IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'UserView') +BEGIN + DROP VIEW [dbo].[UserView] +END +GO + +CREATE VIEW [dbo].[UserView] +AS +SELECT + * +FROM + [dbo].[User] +GO