diff --git a/src/Core/Models/Api/Response/ProfileOrganizationResponseModel.cs b/src/Core/Models/Api/Response/ProfileOrganizationResponseModel.cs index 6b30e9eb68..7f829d5ad8 100644 --- a/src/Core/Models/Api/Response/ProfileOrganizationResponseModel.cs +++ b/src/Core/Models/Api/Response/ProfileOrganizationResponseModel.cs @@ -10,6 +10,9 @@ namespace Bit.Core.Models.Api { Id = organization.OrganizationId.ToString(); Name = organization.Name; + UseGroups = organization.UseGroups; + Seats = organization.Seats; + MaxCollections = organization.MaxCollections; Key = organization.Key; Status = organization.Status; Type = organization.Type; @@ -18,6 +21,9 @@ namespace Bit.Core.Models.Api public string Id { get; set; } public string Name { get; set; } + public bool UseGroups { get; set; } + public int Seats { get; set; } + public int MaxCollections { get; set; } public string Key { get; set; } public OrganizationUserStatusType Status { get; set; } public OrganizationUserType Type { get; set; } diff --git a/src/Core/Models/Data/OrganizationUserOrganizationDetails.cs b/src/Core/Models/Data/OrganizationUserOrganizationDetails.cs index ade2c5cdbf..278eac0ea3 100644 --- a/src/Core/Models/Data/OrganizationUserOrganizationDetails.cs +++ b/src/Core/Models/Data/OrganizationUserOrganizationDetails.cs @@ -7,6 +7,9 @@ namespace Bit.Core.Models.Data public Guid OrganizationId { get; set; } public Guid? UserId { get; set; } public string Name { get; set; } + public bool UseGroups { get; set; } + public int Seats { get; set; } + public int MaxCollections { get; set; } public string Key { get; set; } public Enums.OrganizationUserStatusType Status { get; set; } public Enums.OrganizationUserType Type { get; set; } diff --git a/src/Core/Models/Table/Organization.cs b/src/Core/Models/Table/Organization.cs index 64fdf9ee37..b5da58e728 100644 --- a/src/Core/Models/Table/Organization.cs +++ b/src/Core/Models/Table/Organization.cs @@ -14,6 +14,7 @@ namespace Bit.Core.Models.Table public PlanType PlanType { get; set; } public short? Seats { get; set; } public short? MaxCollections { get; set; } + public bool UseGroups { get; set; } public string StripeCustomerId { get; set; } public string StripeSubscriptionId { get; set; } public bool Enabled { get; set; } = true; diff --git a/src/Sql/dbo/Stored Procedures/Organization_Create.sql b/src/Sql/dbo/Stored Procedures/Organization_Create.sql index 3a40e291a9..52725a47a2 100644 --- a/src/Sql/dbo/Stored Procedures/Organization_Create.sql +++ b/src/Sql/dbo/Stored Procedures/Organization_Create.sql @@ -7,6 +7,7 @@ @PlanType TINYINT, @Seats SMALLINT, @MaxCollections SMALLINT, + @UseGroups BIT, @StripeCustomerId VARCHAR(50), @StripeSubscriptionId VARCHAR(50), @Enabled BIT, @@ -26,6 +27,7 @@ BEGIN [PlanType], [Seats], [MaxCollections], + [UseGroups], [StripeCustomerId], [StripeSubscriptionId], [Enabled], @@ -42,6 +44,7 @@ BEGIN @PlanType, @Seats, @MaxCollections, + @UseGroups, @StripeCustomerId, @StripeSubscriptionId, @Enabled, diff --git a/src/Sql/dbo/Stored Procedures/Organization_Update.sql b/src/Sql/dbo/Stored Procedures/Organization_Update.sql index 9ab30dae9c..099e1cd467 100644 --- a/src/Sql/dbo/Stored Procedures/Organization_Update.sql +++ b/src/Sql/dbo/Stored Procedures/Organization_Update.sql @@ -7,6 +7,7 @@ @PlanType TINYINT, @Seats SMALLINT, @MaxCollections SMALLINT, + @UseGroups BIT, @StripeCustomerId VARCHAR(50), @StripeSubscriptionId VARCHAR(50), @Enabled BIT, @@ -27,6 +28,7 @@ BEGIN [PlanType] = @PlanType, [Seats] = @Seats, [MaxCollections] = @MaxCollections, + [UseGroups] = @UseGroups, [StripeCustomerId] = @StripeCustomerId, [StripeSubscriptionId] = @StripeSubscriptionId, [Enabled] = @Enabled, diff --git a/src/Sql/dbo/Tables/Organization.sql b/src/Sql/dbo/Tables/Organization.sql index ba98350895..860d3f25d2 100644 --- a/src/Sql/dbo/Tables/Organization.sql +++ b/src/Sql/dbo/Tables/Organization.sql @@ -7,6 +7,7 @@ [PlanType] TINYINT NOT NULL, [Seats] SMALLINT NULL, [MaxCollections] SMALLINT NULL, + [UseGroups] BIT NOT NULL, [StripeCustomerId] VARCHAR (50) NULL, [StripeSubscriptionId] VARCHAR (50) NULL, [Enabled] BIT NOT NULL, diff --git a/src/Sql/dbo/Views/OrganizationUserOrganizationDetailsView.sql b/src/Sql/dbo/Views/OrganizationUserOrganizationDetailsView.sql index 9c8794fdc3..1f064addc2 100644 --- a/src/Sql/dbo/Views/OrganizationUserOrganizationDetailsView.sql +++ b/src/Sql/dbo/Views/OrganizationUserOrganizationDetailsView.sql @@ -5,6 +5,9 @@ SELECT OU.[OrganizationId], O.[Name], O.[Enabled], + O.[UseGroups], + O.[Seats], + O.[MaxCollections], OU.[Key], OU.[Status], OU.[Type] diff --git a/src/SqlUpdate/2017-01-03_01_TableAdjustments.sql b/src/SqlUpdate/2017-01-03_01_TableAdjustments.sql deleted file mode 100644 index 039b979414..0000000000 --- a/src/SqlUpdate/2017-01-03_01_TableAdjustments.sql +++ /dev/null @@ -1,27 +0,0 @@ --- Get rid of history table - -DROP TABLE [History] -GO - --- Setup new tables - -CREATE TABLE [dbo].[Folder] ( - [Id] UNIQUEIDENTIFIER NOT NULL, - [UserId] UNIQUEIDENTIFIER NOT NULL, - [Name] VARCHAR (MAX) NULL, - [CreationDate] DATETIME2 (7) NOT NULL, - [RevisionDate] DATETIME2 (7) NOT NULL, - CONSTRAINT [PK_Folder] PRIMARY KEY CLUSTERED ([Id] ASC) -) -GO - --- Setup new columns for cipher changes - -ALTER TABLE [dbo].[Cipher] -ADD [Favorites] VARCHAR(MAX) NULL -GO - -ALTER TABLE [dbo].[Cipher] -ADD [Folders] VARCHAR(MAX) NULL -GO - diff --git a/src/SqlUpdate/2017-05-08_00_OrgUseGroups.sql b/src/SqlUpdate/2017-05-08_00_OrgUseGroups.sql new file mode 100644 index 0000000000..f06d02467b --- /dev/null +++ b/src/SqlUpdate/2017-05-08_00_OrgUseGroups.sql @@ -0,0 +1,6 @@ +alter table [organization] add [UseGroups] bit null +go +update [organization] set UseGroups = 0 +go +alter table [organization] alter column [UseGroups] bit not null +go \ No newline at end of file diff --git a/src/SqlUpdate/2017-16-03_01_CipherMigration.sql b/src/SqlUpdate/2017-16-03_01_CipherMigration.sql deleted file mode 100644 index 81934c1e63..0000000000 --- a/src/SqlUpdate/2017-16-03_01_CipherMigration.sql +++ /dev/null @@ -1,40 +0,0 @@ --- Step 0, Disable old triggers - -ALTER TABLE cipher DISABLE TRIGGER Cipher_Deleted -GO -ALTER TABLE cipher DISABLE TRIGGER Cipher_Updated -GO -ALTER TABLE cipher DISABLE TRIGGER Cipher_Inserted -GO - --- Step 1, Run each statement individually - -insert into folder -select Id, UserId, JSON_VALUE(Data,'$.Name') AS [Name], CreationDate, RevisionDate -from cipher -where [type] = 0 - -update cipher set -Folders = concat('{"', userid, '":"', folderid, '"}') -where [userid] is not null -and [folderid] is not null - -update cipher set -Favorites = concat('{"', userid, '":true}') -where [Favorite] = 1 - --- Step 2, verify data migration from step 1 then drop each column - -alter table cipher drop constraint [FK_Cipher_Folder] -go - -alter table cipher drop column FolderId -go - -alter table cipher drop column Favorite -go - --- Step 3, delete old folder ciphers - -delete from cipher where [type] = 0 -