mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-05-18 09:33:56 +00:00
Add per-user folder-cipher mapping
This commit is contained in:
parent
f578019df6
commit
514a372bc8
11 changed files with 217 additions and 49 deletions
32
migrations/2018-04-27-155151_create_users_ciphers/up.sql
Normal file
32
migrations/2018-04-27-155151_create_users_ciphers/up.sql
Normal file
|
@ -0,0 +1,32 @@
|
|||
ALTER TABLE ciphers RENAME TO oldCiphers;
|
||||
|
||||
CREATE TABLE ciphers (
|
||||
uuid TEXT NOT NULL PRIMARY KEY,
|
||||
created_at DATETIME NOT NULL,
|
||||
updated_at DATETIME NOT NULL,
|
||||
user_uuid TEXT REFERENCES users (uuid), -- Make this optional
|
||||
organization_uuid TEXT REFERENCES organizations (uuid), -- Add reference to orgs table
|
||||
-- Remove folder_uuid
|
||||
type INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
notes TEXT,
|
||||
fields TEXT,
|
||||
data TEXT NOT NULL,
|
||||
favorite BOOLEAN NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE folders_ciphers (
|
||||
cipher_uuid TEXT NOT NULL REFERENCES ciphers (uuid),
|
||||
folder_uuid TEXT NOT NULL REFERENCES folders (uuid),
|
||||
|
||||
PRIMARY KEY (cipher_uuid, folder_uuid)
|
||||
);
|
||||
|
||||
INSERT INTO ciphers (uuid, created_at, updated_at, organization_uuid, type, name, notes, fields, data, favorite)
|
||||
SELECT uuid, created_at, updated_at, organization_uuid, type, name, notes, fields, data, favorite FROM oldCiphers;
|
||||
|
||||
INSERT INTO folders_ciphers (cipher_uuid, folder_uuid)
|
||||
SELECT uuid, folder_uuid FROM oldCiphers WHERE folder_uuid IS NOT NULL;
|
||||
|
||||
|
||||
DROP TABLE oldCiphers;
|
Loading…
Add table
Add a link
Reference in a new issue