aboutsummaryrefslogtreecommitdiff
path: root/migrations
diff options
context:
space:
mode:
authorMiroslav Prasil <[email protected]>2018-04-30 10:52:15 +0100
committerMiroslav Prasil <[email protected]>2018-04-30 23:38:55 +0100
commit514a372bc85fd495d331f240e35377a8ebdfb3c4 (patch)
treeb5f27066da0093064c984a97fee5101ac192386d /migrations
parentf578019df6597cf130c0e7879478271bf4193dbc (diff)
downloadvaultwarden-514a372bc85fd495d331f240e35377a8ebdfb3c4.tar.gz
vaultwarden-514a372bc85fd495d331f240e35377a8ebdfb3c4.zip
Add per-user folder-cipher mapping
Diffstat (limited to 'migrations')
-rw-r--r--migrations/2018-04-27-155151_create_users_ciphers/up.sql32
1 files changed, 32 insertions, 0 deletions
diff --git a/migrations/2018-04-27-155151_create_users_ciphers/up.sql b/migrations/2018-04-27-155151_create_users_ciphers/up.sql
new file mode 100644
index 00000000..a0788791
--- /dev/null
+++ b/migrations/2018-04-27-155151_create_users_ciphers/up.sql
@@ -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; \ No newline at end of file