mirror of
https://github.com/bitwarden/server.git
synced 2025-01-04 19:07:50 +01:00
update migration scripts for json favs/folders
This commit is contained in:
parent
a684e03819
commit
94043d5006
@ -5,13 +5,6 @@ GO
|
|||||||
|
|
||||||
-- Setup new tables
|
-- Setup new tables
|
||||||
|
|
||||||
CREATE TABLE [dbo].[Favorite] (
|
|
||||||
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
|
||||||
[CipherId] UNIQUEIDENTIFIER NOT NULL,
|
|
||||||
CONSTRAINT [PK_Favorite] PRIMARY KEY CLUSTERED ([UserId] ASC, [CipherId] ASC)
|
|
||||||
)
|
|
||||||
GO
|
|
||||||
|
|
||||||
CREATE TABLE [dbo].[Folder] (
|
CREATE TABLE [dbo].[Folder] (
|
||||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||||
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
||||||
@ -22,13 +15,13 @@ CREATE TABLE [dbo].[Folder] (
|
|||||||
)
|
)
|
||||||
GO
|
GO
|
||||||
|
|
||||||
CREATE TABLE [dbo].[FolderCipher] (
|
-- Setup new columns for cipher changes
|
||||||
[FolderId] UNIQUEIDENTIFIER NOT NULL,
|
|
||||||
[CipherId] UNIQUEIDENTIFIER NOT NULL,
|
ALTER TABLE [dbo].[Cipher]
|
||||||
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
ADD [Favorites] VARCHAR(MAX) NULL
|
||||||
CONSTRAINT [PK_FolderCipher] PRIMARY KEY CLUSTERED ([UserId] ASC, [FolderId] ASC, [CipherId] ASC)
|
|
||||||
)
|
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
ALTER TABLE [dbo].[Cipher]
|
||||||
|
ADD [Folders] VARCHAR(MAX) NULL
|
||||||
|
GO
|
||||||
|
|
||||||
|
@ -5,18 +5,16 @@ select Id, UserId, JSON_VALUE(Data,'$.Name') AS [Name], CreationDate, RevisionDa
|
|||||||
from cipher
|
from cipher
|
||||||
where [type] = 0
|
where [type] = 0
|
||||||
|
|
||||||
insert into foldercipher
|
update cipher set
|
||||||
select FolderId, Id, UserId
|
Folders = concat('{"', userid, '":"', folderid, '"}')
|
||||||
from cipher
|
where [userid] is not null
|
||||||
where [FolderId] is not null
|
and [folderid] is not null
|
||||||
|
|
||||||
insert into favorite
|
update cipher set
|
||||||
select UserId, [Id]
|
Favorites = concat('{"', userid, '":true}')
|
||||||
from cipher
|
where [Favorite] = 1
|
||||||
where Favorite = 1
|
|
||||||
|
|
||||||
|
-- Step 2, verify data migration from step 1 then drop each column
|
||||||
-- Step 2, drop each column
|
|
||||||
|
|
||||||
alter table cipher drop constraint [FK_Cipher_Folder]
|
alter table cipher drop constraint [FK_Cipher_Folder]
|
||||||
go
|
go
|
||||||
|
Loading…
Reference in New Issue
Block a user