diff --git a/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs b/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs index d9bfe59dc..05911c1d9 100644 --- a/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs +++ b/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs @@ -44,14 +44,12 @@ namespace Bit.Core.Models.Api { [Required] public string SubvaultId { get; set; } - public bool Admin { get; set; } public bool ReadOnly { get; set; } public SubvaultUser ToSubvaultUser() { var subvault = new SubvaultUser { - Admin = Admin, ReadOnly = ReadOnly, SubvaultId = new Guid(SubvaultId) }; diff --git a/src/Core/Models/Api/Request/SubvaultUserRequestModel.cs b/src/Core/Models/Api/Request/SubvaultUserRequestModel.cs index 9756b6ec0..9245965ab 100644 --- a/src/Core/Models/Api/Request/SubvaultUserRequestModel.cs +++ b/src/Core/Models/Api/Request/SubvaultUserRequestModel.cs @@ -1,9 +1,5 @@ using System; -using System.ComponentModel.DataAnnotations; -using Bit.Core.Utilities; using Bit.Core.Models.Table; -using Newtonsoft.Json; -using System.Collections; using System.Collections.Generic; using System.Linq; @@ -20,7 +16,6 @@ namespace Bit.Core.Models.Api { OrganizationUserId = new Guid(UserId), SubvaultId = new Guid(s.SubvaultId), - Admin = s.Admin, ReadOnly = s.ReadOnly }); } @@ -28,7 +23,6 @@ namespace Bit.Core.Models.Api public class Subvault { public string SubvaultId { get; set; } - public bool Admin { get; set; } public bool ReadOnly { get; set; } } } @@ -36,7 +30,6 @@ namespace Bit.Core.Models.Api public class SubvaultUserUserRequestModel { public string UserId { get; set; } - public bool Admin { get; set; } public bool ReadOnly { get; set; } } } diff --git a/src/Core/Models/Api/Response/OrganizationResponseModel.cs b/src/Core/Models/Api/Response/OrganizationResponseModel.cs index 422ebf170..b491624ee 100644 --- a/src/Core/Models/Api/Response/OrganizationResponseModel.cs +++ b/src/Core/Models/Api/Response/OrganizationResponseModel.cs @@ -23,7 +23,6 @@ namespace Bit.Core.Models.Api BillingEmail = organization.BillingEmail; Plan = organization.Plan; PlanType = organization.PlanType; - PlanTrial = organization.PlanTrial; MaxUsers = organization.MaxUsers; } @@ -33,7 +32,6 @@ namespace Bit.Core.Models.Api public string BillingEmail { get; set; } public string Plan { get; set; } public Enums.PlanType PlanType { get; set; } - public bool PlanTrial { get; set; } public short MaxUsers { get; set; } } diff --git a/src/Core/Models/Api/Response/OrganizationUserSubvaultResponseModel.cs b/src/Core/Models/Api/Response/OrganizationUserSubvaultResponseModel.cs index cbce09510..9a5299f16 100644 --- a/src/Core/Models/Api/Response/OrganizationUserSubvaultResponseModel.cs +++ b/src/Core/Models/Api/Response/OrganizationUserSubvaultResponseModel.cs @@ -18,13 +18,11 @@ namespace Bit.Core.Models.Api Name = details.Name; SubvaultId = details.SubvaultId.ToString(); ReadOnly = details.ReadOnly; - Admin = details.Admin; } public string Id { get; set; } public string Name { get; set; } public string SubvaultId { get; set; } public bool ReadOnly { get; set; } - public bool Admin { get; set; } } } diff --git a/src/Core/Models/Api/Response/SubvaultUserResponseModel.cs b/src/Core/Models/Api/Response/SubvaultUserResponseModel.cs index 72e624730..044e4702a 100644 --- a/src/Core/Models/Api/Response/SubvaultUserResponseModel.cs +++ b/src/Core/Models/Api/Response/SubvaultUserResponseModel.cs @@ -23,7 +23,6 @@ namespace Bit.Core.Models.Api Type = subvaultUser.Type; Status = subvaultUser.Status; ReadOnly = subvaultUser.ReadOnly; - Admin = subvaultUser.Admin; } public string Id { get; set; } @@ -34,6 +33,5 @@ namespace Bit.Core.Models.Api public OrganizationUserType Type { get; set; } public OrganizationUserStatusType Status { get; set; } public bool ReadOnly { get; set; } - public bool Admin { get; set; } } } diff --git a/src/Core/Models/Data/SubvaultUserPermissions.cs b/src/Core/Models/Data/SubvaultUserPermissions.cs index 0f121359d..93edf4b3d 100644 --- a/src/Core/Models/Data/SubvaultUserPermissions.cs +++ b/src/Core/Models/Data/SubvaultUserPermissions.cs @@ -6,6 +6,5 @@ namespace Bit.Core.Models.Data { public Guid SubvaultId { get; set; } public bool ReadOnly { get; set; } - public bool Admin { get; set; } } } diff --git a/src/Core/Models/Data/SubvaultUserSubvaultDetails.cs b/src/Core/Models/Data/SubvaultUserSubvaultDetails.cs index 404b7cdfa..71b906a5a 100644 --- a/src/Core/Models/Data/SubvaultUserSubvaultDetails.cs +++ b/src/Core/Models/Data/SubvaultUserSubvaultDetails.cs @@ -9,6 +9,5 @@ namespace Bit.Core.Models.Data public string Name { get; set; } public Guid SubvaultId { get; set; } public bool ReadOnly { get; set; } - public bool Admin { get; set; } } } diff --git a/src/Core/Models/Data/SubvaultUserUserDetails.cs b/src/Core/Models/Data/SubvaultUserUserDetails.cs index d21fecb5b..aaf7b6674 100644 --- a/src/Core/Models/Data/SubvaultUserUserDetails.cs +++ b/src/Core/Models/Data/SubvaultUserUserDetails.cs @@ -12,6 +12,5 @@ namespace Bit.Core.Models.Data public Enums.OrganizationUserStatusType Status { get; set; } public Enums.OrganizationUserType Type { get; set; } public bool ReadOnly { get; set; } - public bool Admin { get; set; } } } diff --git a/src/Core/Models/Table/Organization.cs b/src/Core/Models/Table/Organization.cs index d9063888a..69f3de44c 100644 --- a/src/Core/Models/Table/Organization.cs +++ b/src/Core/Models/Table/Organization.cs @@ -13,12 +13,6 @@ namespace Bit.Core.Models.Table public string BillingEmail { get; set; } public string Plan { get; set; } public PlanType PlanType { get; set; } - public decimal PlanBasePrice { get; set; } - public decimal PlanUserPrice { get; set; } - public DateTime? PlanRenewalDate { get; set; } - public bool PlanTrial { get; set; } - public short BaseUsers { get; set; } - public short AdditionalUsers { get; set; } public short MaxUsers { get; set; } public string StripeCustomerId { get; set; } public string StripeSubscriptionId { get; set; } diff --git a/src/Core/Models/Table/SubvaultUser.cs b/src/Core/Models/Table/SubvaultUser.cs index fce505549..b6dba5c7b 100644 --- a/src/Core/Models/Table/SubvaultUser.cs +++ b/src/Core/Models/Table/SubvaultUser.cs @@ -8,7 +8,6 @@ namespace Bit.Core.Models.Table public Guid Id { get; set; } public Guid SubvaultId { get; set; } public Guid OrganizationUserId { get; set; } - public bool Admin { get; set; } public bool ReadOnly { get; set; } public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow; diff --git a/src/Core/Repositories/IOrganizationUserRepository.cs b/src/Core/Repositories/IOrganizationUserRepository.cs index e418d6d1e..6a7c31c7a 100644 --- a/src/Core/Repositories/IOrganizationUserRepository.cs +++ b/src/Core/Repositories/IOrganizationUserRepository.cs @@ -9,6 +9,7 @@ namespace Bit.Core.Repositories { public interface IOrganizationUserRepository : IRepository { + Task GetCountByFreeOrganizationAdminUserAsync(Guid userId); Task> GetManyByUserAsync(Guid userId); Task> GetManyByOrganizationAsync(Guid organizationId, OrganizationUserType? type); Task GetByOrganizationAsync(Guid organizationId, string email); diff --git a/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs b/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs index 729c6f30a..f6e792dac 100644 --- a/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs +++ b/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs @@ -21,6 +21,19 @@ namespace Bit.Core.Repositories.SqlServer : base(connectionString) { } + public async Task GetCountByFreeOrganizationAdminUserAsync(Guid userId) + { + using(var connection = new SqlConnection(ConnectionString)) + { + var results = await connection.ExecuteScalarAsync( + "[dbo].[OrganizationUser_ReadCountByFreeOrganizationAdminUser]", + new { UserId = userId }, + commandType: CommandType.StoredProcedure); + + return results; + } + } + public async Task GetByOrganizationAsync(Guid organizationId, string email) { using(var connection = new SqlConnection(ConnectionString)) diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 91538ace0..90f23ea03 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -89,9 +89,9 @@ namespace Bit.Core.Services if(plan.Type == Enums.PlanType.Free) { - var ownerExistingOrgs = await _organizationUserRepository.GetManyByUserAsync(signup.Owner.Id); - if(ownerExistingOrgs.Any(ou => ou.Type == Enums.OrganizationUserType.Owner || - ou.Type == Enums.OrganizationUserType.Admin)) + var ownerExistingOrgCount = + await _organizationUserRepository.GetCountByFreeOrganizationAdminUserAsync(signup.Owner.Id); + if(ownerExistingOrgCount > 0) { throw new BadRequestException("You can only be an admin of one free organization."); } @@ -136,13 +136,7 @@ namespace Bit.Core.Services BusinessName = signup.BusinessName, UserId = signup.Owner.Id, PlanType = plan.Type, - BaseUsers = plan.BaseUsers, - AdditionalUsers = (short)(plan.CanBuyAdditionalUsers ? signup.AdditionalUsers : 0), MaxUsers = (short)(plan.BaseUsers + (plan.CanBuyAdditionalUsers ? signup.AdditionalUsers : 0)), - PlanTrial = plan.Trial.HasValue, - PlanBasePrice = plan.CanMonthly && signup.Monthly ? plan.BaseMonthlyPrice : plan.BaseAnnualPrice, - PlanUserPrice = plan.CanMonthly && signup.Monthly ? plan.UserMonthlyPrice : plan.UserAnnualPrice, - PlanRenewalDate = subscription?.CurrentPeriodEnd, Plan = plan.ToString(), StripeCustomerId = customer?.Id, StripeSubscriptionId = subscription?.Id, @@ -254,8 +248,8 @@ namespace Bit.Core.Services throw new BadRequestException("Already accepted."); } - var existingOrgs = await _organizationUserRepository.GetManyByUserAsync(user.Id); - if(existingOrgs.Any(ou => ou.Type == Enums.OrganizationUserType.Owner || ou.Type == Enums.OrganizationUserType.Admin)) + var ownerExistingOrgCount = await _organizationUserRepository.GetCountByFreeOrganizationAdminUserAsync(user.Id); + if(ownerExistingOrgCount > 0) { throw new BadRequestException("You can only be an admin of one free organization."); } diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj index 8ead6e47c..aeb902c97 100644 --- a/src/Sql/Sql.sqlproj +++ b/src/Sql/Sql.sqlproj @@ -99,8 +99,11 @@ + + + @@ -178,7 +181,5 @@ - - \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/OrganizationUser_ReadCountByFreeOrganizationAdminUser.sql b/src/Sql/dbo/Stored Procedures/OrganizationUser_ReadCountByFreeOrganizationAdminUser.sql new file mode 100644 index 000000000..8dd25a15a --- /dev/null +++ b/src/Sql/dbo/Stored Procedures/OrganizationUser_ReadCountByFreeOrganizationAdminUser.sql @@ -0,0 +1,17 @@ +CREATE PROCEDURE [dbo].[OrganizationUser_ReadCountByFreeOrganizationAdminUser] + @UserId UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT + COUNT(1) + FROM + [dbo].[OrganizationUser] OU + INNER JOIN + [dbo].[Organization] O ON O.Id = OU.[OrganizationId] + WHERE + OU.[UserId] = @UserId + AND OU.[Type] < 2 -- Owner or Admin + AND O.[PlanType] = 0 -- Free +END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Organization_Create.sql b/src/Sql/dbo/Stored Procedures/Organization_Create.sql index ef10df804..89e9bea0a 100644 --- a/src/Sql/dbo/Stored Procedures/Organization_Create.sql +++ b/src/Sql/dbo/Stored Procedures/Organization_Create.sql @@ -1,17 +1,10 @@ CREATE PROCEDURE [dbo].[Organization_Create] @Id UNIQUEIDENTIFIER, - @UserId UNIQUEIDENTIFIER, @Name NVARCHAR(50), @BusinessName NVARCHAR(50), @BillingEmail NVARCHAR(50), @Plan NVARCHAR(20), @PlanType TINYINT, - @PlanBasePrice MONEY, - @PlanUserPrice MONEY, - @PlanRenewalDate DATETIME2(7), - @PlanTrial BIT, - @BaseUsers SMALLINT, - @AdditionalUsers SMALLINT, @MaxUsers SMALLINT, @StripeCustomerId VARCHAR(50), @StripeSubscriptionId VARCHAR(50), @@ -24,18 +17,11 @@ BEGIN INSERT INTO [dbo].[Organization] ( [Id], - [UserId], [Name], [BusinessName], [BillingEmail], [Plan], [PlanType], - [PlanBasePrice], - [PlanUserPrice], - [PlanRenewalDate], - [PlanTrial], - [BaseUsers], - [AdditionalUsers], [MaxUsers], [StripeCustomerId], [StripeSubscriptionId], @@ -45,18 +31,11 @@ BEGIN VALUES ( @Id, - @UserId, @Name, @BusinessName, @BillingEmail, @Plan, @PlanType, - @PlanBasePrice, - @PlanUserPrice, - @PlanRenewalDate, - @PlanTrial, - @BaseUsers, - @AdditionalUsers, @MaxUsers, @StripeCustomerId, @StripeSubscriptionId, diff --git a/src/Sql/dbo/Stored Procedures/Organization_Update.sql b/src/Sql/dbo/Stored Procedures/Organization_Update.sql index ba3ba85d8..a8eb69f6c 100644 --- a/src/Sql/dbo/Stored Procedures/Organization_Update.sql +++ b/src/Sql/dbo/Stored Procedures/Organization_Update.sql @@ -1,17 +1,10 @@ CREATE PROCEDURE [dbo].[Organization_Update] @Id UNIQUEIDENTIFIER, - @UserId UNIQUEIDENTIFIER, @Name NVARCHAR(50), @BusinessName NVARCHAR(50), @BillingEmail NVARCHAR(50), @Plan NVARCHAR(20), @PlanType TINYINT, - @PlanBasePrice MONEY, - @PlanUserPrice MONEY, - @PlanRenewalDate DATETIME2(7), - @PlanTrial BIT, - @BaseUsers SMALLINT, - @AdditionalUsers SMALLINT, @MaxUsers SMALLINT, @StripeCustomerId VARCHAR(50), @StripeSubscriptionId VARCHAR(50), @@ -25,18 +18,11 @@ BEGIN UPDATE [dbo].[Organization] SET - [UserId] = @UserId, [Name] = @Name, [BusinessName] = @BusinessName, [BillingEmail] = @BillingEmail, [Plan] = @Plan, [PlanType] = @PlanType, - [PlanBasePrice] = @PlanBasePrice, - [PlanUserPrice] = @PlanUserPrice, - [PlanRenewalDate] = @PlanRenewalDate, - [PlanTrial] = @PlanTrial, - [BaseUsers] = @BaseUsers, - [AdditionalUsers] = @AdditionalUsers, [MaxUsers] = @MaxUsers, [StripeCustomerId] = @StripeCustomerId, [StripeSubscriptionId] = @StripeSubscriptionId, diff --git a/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByCipherId.sql b/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserIdCipherId.sql similarity index 100% rename from src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByCipherId.sql rename to src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserIdCipherId.sql diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_Create.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_Create.sql index b2e5f206f..84039d4a9 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_Create.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_Create.sql @@ -2,7 +2,6 @@ @Id UNIQUEIDENTIFIER, @SubvaultId UNIQUEIDENTIFIER, @OrganizationUserId UNIQUEIDENTIFIER, - @Admin BIT, @ReadOnly BIT, @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) @@ -15,7 +14,6 @@ BEGIN [Id], [SubvaultId], [OrganizationUserId], - [Admin], [ReadOnly], [CreationDate], [RevisionDate] @@ -25,7 +23,6 @@ BEGIN @Id, @SubvaultId, @OrganizationUserId, - @Admin, @ReadOnly, @CreationDate, @RevisionDate diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadPermissionsBySubvaultUserId.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadPermissionsBySubvaultUserId.sql index 61259aab8..8a395ae7f 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadPermissionsBySubvaultUserId.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadPermissionsBySubvaultUserId.sql @@ -8,7 +8,6 @@ BEGIN SELECT SU.[SubvaultId], - CASE WHEN OU.[Type] = 2 THEN SU.[Admin] ELSE 1 END AS [Admin], -- 2 = Regular User SU.[ReadOnly] FROM [dbo].[SubvaultUser] SU diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_Update.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_Update.sql index a96d77b3a..09e65a4db 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_Update.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_Update.sql @@ -2,7 +2,6 @@ @Id UNIQUEIDENTIFIER, @SubvaultId UNIQUEIDENTIFIER, @OrganizationUserId UNIQUEIDENTIFIER, - @Admin BIT, @ReadOnly BIT, @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) @@ -15,7 +14,6 @@ BEGIN SET [SubvaultId] = @SubvaultId, [OrganizationUserId] = @OrganizationUserId, - [Admin] = @Admin, [ReadOnly] = @ReadOnly, [CreationDate] = @CreationDate, [RevisionDate] = @RevisionDate diff --git a/src/Sql/dbo/Tables/Group.sql b/src/Sql/dbo/Tables/Group.sql index 45111f54a..b26245b91 100644 --- a/src/Sql/dbo/Tables/Group.sql +++ b/src/Sql/dbo/Tables/Group.sql @@ -5,6 +5,6 @@ [CreationDate] DATETIME NOT NULL, [RevisionDate] DATETIME NOT NULL, CONSTRAINT [PK_Group] PRIMARY KEY CLUSTERED ([Id] ASC), - CONSTRAINT [FK_Group_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) + CONSTRAINT [FK_Group_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE ); diff --git a/src/Sql/dbo/Tables/Organization.sql b/src/Sql/dbo/Tables/Organization.sql index bae5de360..4321c8cb9 100644 --- a/src/Sql/dbo/Tables/Organization.sql +++ b/src/Sql/dbo/Tables/Organization.sql @@ -1,23 +1,15 @@ CREATE TABLE [dbo].[Organization] ( [Id] UNIQUEIDENTIFIER NOT NULL, - [UserId] UNIQUEIDENTIFIER NOT NULL, [Name] NVARCHAR (50) NOT NULL, [BusinessName] NVARCHAR (50) NULL, [BillingEmail] NVARCHAR (50) NOT NULL, [Plan] NVARCHAR (20) NOT NULL, [PlanType] TINYINT NOT NULL, - [PlanBasePrice] MONEY NOT NULL, - [PlanUserPrice] MONEY NOT NULL, - [PlanRenewalDate] DATETIME2 (7) NULL, - [PlanTrial] BIT NOT NULL, - [BaseUsers] SMALLINT NULL, - [AdditionalUsers] SMALLINT NULL, [MaxUsers] SMALLINT NULL, [StripeCustomerId] VARCHAR (50) NULL, [StripeSubscriptionId] VARCHAR (50) NULL, [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, - CONSTRAINT [PK_Organization] PRIMARY KEY CLUSTERED ([Id] ASC), - CONSTRAINT [FK_Organization_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) + CONSTRAINT [PK_Organization] PRIMARY KEY CLUSTERED ([Id] ASC) ); diff --git a/src/Sql/dbo/Tables/OrganizationUser.sql b/src/Sql/dbo/Tables/OrganizationUser.sql index aebdf9306..7d5d89002 100644 --- a/src/Sql/dbo/Tables/OrganizationUser.sql +++ b/src/Sql/dbo/Tables/OrganizationUser.sql @@ -9,7 +9,7 @@ [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC), - CONSTRAINT [FK_OrganizationUser_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]), + CONSTRAINT [FK_OrganizationUser_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE, CONSTRAINT [FK_OrganizationUser_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) ); diff --git a/src/Sql/dbo/Tables/Subvault.sql b/src/Sql/dbo/Tables/Subvault.sql index 1ca904af8..5f332bae5 100644 --- a/src/Sql/dbo/Tables/Subvault.sql +++ b/src/Sql/dbo/Tables/Subvault.sql @@ -5,6 +5,6 @@ [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, CONSTRAINT [PK_Subvault] PRIMARY KEY CLUSTERED ([Id] ASC), - CONSTRAINT [FK_Subvault_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) + CONSTRAINT [FK_Subvault_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE ); diff --git a/src/Sql/dbo/Tables/SubvaultGroup.sql b/src/Sql/dbo/Tables/SubvaultGroup.sql index 4551dbf13..2c4f885a7 100644 --- a/src/Sql/dbo/Tables/SubvaultGroup.sql +++ b/src/Sql/dbo/Tables/SubvaultGroup.sql @@ -3,6 +3,6 @@ [GroupId] UNIQUEIDENTIFIER NOT NULL, CONSTRAINT [PK_SubvaultGroup] PRIMARY KEY CLUSTERED ([SubvaultId] ASC, [GroupId] ASC), CONSTRAINT [FK_SubvaultGroup_Group] FOREIGN KEY ([GroupId]) REFERENCES [dbo].[Group] ([Id]) ON DELETE CASCADE, - CONSTRAINT [FK_SubvaultGroup_Subvault] FOREIGN KEY ([SubvaultId]) REFERENCES [dbo].[Subvault] ([Id]) ON DELETE CASCADE + CONSTRAINT [FK_SubvaultGroup_Subvault] FOREIGN KEY ([SubvaultId]) REFERENCES [dbo].[Subvault] ([Id]) ); diff --git a/src/Sql/dbo/Tables/SubvaultUser.sql b/src/Sql/dbo/Tables/SubvaultUser.sql index 878b38364..57f570df6 100644 --- a/src/Sql/dbo/Tables/SubvaultUser.sql +++ b/src/Sql/dbo/Tables/SubvaultUser.sql @@ -2,12 +2,11 @@ [Id] UNIQUEIDENTIFIER NOT NULL, [SubvaultId] UNIQUEIDENTIFIER NOT NULL, [OrganizationUserId] UNIQUEIDENTIFIER NOT NULL, - [Admin] BIT NOT NULL, [ReadOnly] BIT NOT NULL, [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, CONSTRAINT [PK_SubvaultUser] PRIMARY KEY CLUSTERED ([Id] ASC), - CONSTRAINT [FK_SubvaultUser_OrganizationUser] FOREIGN KEY ([OrganizationUserId]) REFERENCES [dbo].[OrganizationUser] ([Id]) ON DELETE CASCADE, + CONSTRAINT [FK_SubvaultUser_OrganizationUser] FOREIGN KEY ([OrganizationUserId]) REFERENCES [dbo].[OrganizationUser] ([Id]), CONSTRAINT [FK_SubvaultUser_Subvault] FOREIGN KEY ([SubvaultId]) REFERENCES [dbo].[Subvault] ([Id]) ON DELETE CASCADE ); diff --git a/src/Sql/dbo/Views/SubvaultUserSubvaultDetailsView.sql b/src/Sql/dbo/Views/SubvaultUserSubvaultDetailsView.sql index 23e9bcf2b..88193f2e8 100644 --- a/src/Sql/dbo/Views/SubvaultUserSubvaultDetailsView.sql +++ b/src/Sql/dbo/Views/SubvaultUserSubvaultDetailsView.sql @@ -5,8 +5,7 @@ SELECT SU.[OrganizationUserId], S.[Name], S.[Id] SubvaultId, - SU.[ReadOnly], - SU.[Admin] + SU.[ReadOnly] FROM [dbo].[SubvaultUser] SU INNER JOIN diff --git a/src/Sql/dbo/Views/SubvaultUserUserDetailsView.sql b/src/Sql/dbo/Views/SubvaultUserUserDetailsView.sql index 5ed4c0b38..29222d545 100644 --- a/src/Sql/dbo/Views/SubvaultUserUserDetailsView.sql +++ b/src/Sql/dbo/Views/SubvaultUserUserDetailsView.sql @@ -8,8 +8,7 @@ SELECT ISNULL(U.[Email], OU.[Email]) Email, OU.[Status], OU.[Type], - SU.[ReadOnly], - SU.[Admin] + SU.[ReadOnly] FROM [dbo].[SubvaultUser] SU INNER JOIN