mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 13:38:13 -05:00
Added use groups bit to org
This commit is contained in:
parent
fdf7546f33
commit
81d4be6f56
@ -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; }
|
||||
|
@ -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; }
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -5,6 +5,9 @@ SELECT
|
||||
OU.[OrganizationId],
|
||||
O.[Name],
|
||||
O.[Enabled],
|
||||
O.[UseGroups],
|
||||
O.[Seats],
|
||||
O.[MaxCollections],
|
||||
OU.[Key],
|
||||
OU.[Status],
|
||||
OU.[Type]
|
||||
|
@ -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
|
||||
|
6
src/SqlUpdate/2017-05-08_00_OrgUseGroups.sql
Normal file
6
src/SqlUpdate/2017-05-08_00_OrgUseGroups.sql
Normal file
@ -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
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user