From 95e24ffc51db2f6834142ec86568c2d244562006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 15 Mar 2021 16:42:20 +0100 Subject: [PATCH] rename send key -> akey --- migrations/mysql/2021-03-11-190243_add_sends/up.sql | 2 +- .../postgresql/2021-03-15-163412_rename_send_key/down.sql | 0 .../postgresql/2021-03-15-163412_rename_send_key/up.sql | 1 + .../sqlite/2021-03-15-163412_rename_send_key/down.sql | 0 .../sqlite/2021-03-15-163412_rename_send_key/up.sql | 1 + src/api/core/sends.rs | 2 +- src/db/models/send.rs | 8 ++++---- src/db/schemas/mysql/schema.rs | 2 +- src/db/schemas/postgresql/schema.rs | 2 +- src/db/schemas/sqlite/schema.rs | 2 +- 10 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 migrations/postgresql/2021-03-15-163412_rename_send_key/down.sql create mode 100644 migrations/postgresql/2021-03-15-163412_rename_send_key/up.sql create mode 100644 migrations/sqlite/2021-03-15-163412_rename_send_key/down.sql create mode 100644 migrations/sqlite/2021-03-15-163412_rename_send_key/up.sql diff --git a/migrations/mysql/2021-03-11-190243_add_sends/up.sql b/migrations/mysql/2021-03-11-190243_add_sends/up.sql index ccc457dc..65b818a4 100644 --- a/migrations/mysql/2021-03-11-190243_add_sends/up.sql +++ b/migrations/mysql/2021-03-11-190243_add_sends/up.sql @@ -8,7 +8,7 @@ CREATE TABLE sends ( atype INTEGER NOT NULL, data TEXT NOT NULL, - key TEXT NOT NULL, + akey TEXT NOT NULL, password_hash BLOB, password_salt BLOB, password_iter INTEGER, diff --git a/migrations/postgresql/2021-03-15-163412_rename_send_key/down.sql b/migrations/postgresql/2021-03-15-163412_rename_send_key/down.sql new file mode 100644 index 00000000..e69de29b diff --git a/migrations/postgresql/2021-03-15-163412_rename_send_key/up.sql b/migrations/postgresql/2021-03-15-163412_rename_send_key/up.sql new file mode 100644 index 00000000..08339fac --- /dev/null +++ b/migrations/postgresql/2021-03-15-163412_rename_send_key/up.sql @@ -0,0 +1 @@ +ALTER TABLE sends RENAME COLUMN key TO akey; diff --git a/migrations/sqlite/2021-03-15-163412_rename_send_key/down.sql b/migrations/sqlite/2021-03-15-163412_rename_send_key/down.sql new file mode 100644 index 00000000..e69de29b diff --git a/migrations/sqlite/2021-03-15-163412_rename_send_key/up.sql b/migrations/sqlite/2021-03-15-163412_rename_send_key/up.sql new file mode 100644 index 00000000..08339fac --- /dev/null +++ b/migrations/sqlite/2021-03-15-163412_rename_send_key/up.sql @@ -0,0 +1 @@ +ALTER TABLE sends RENAME COLUMN key TO akey; diff --git a/src/api/core/sends.rs b/src/api/core/sends.rs index 6fc1dcbc..d14dc57d 100644 --- a/src/api/core/sends.rs +++ b/src/api/core/sends.rs @@ -325,7 +325,7 @@ fn put_send(id: String, data: JsonUpcase, headers: Headers, conn: DbCo } send.data = data_str; send.name = data.Name; - send.key = data.Key; + send.akey = data.Key; send.deletion_date = data.DeletionDate.naive_utc(); send.notes = data.Notes; send.max_access_count = data.MaxAccessCount; diff --git a/src/db/models/send.rs b/src/db/models/send.rs index 674337ed..d7a7a872 100644 --- a/src/db/models/send.rs +++ b/src/db/models/send.rs @@ -22,7 +22,7 @@ db_object! { pub atype: i32, pub data: String, - pub key: String, + pub akey: String, pub password_hash: Option>, password_salt: Option>, password_iter: Option, @@ -46,7 +46,7 @@ pub enum SendType { } impl Send { - pub fn new(atype: i32, name: String, data: String, key: String, deletion_date: NaiveDateTime) -> Self { + pub fn new(atype: i32, name: String, data: String, akey: String, deletion_date: NaiveDateTime) -> Self { let now = Utc::now().naive_utc(); Self { @@ -59,7 +59,7 @@ impl Send { atype, data, - key, + akey, password_hash: None, password_salt: None, password_iter: None, @@ -118,7 +118,7 @@ impl Send { "Text": if self.atype == SendType::Text as i32 { Some(&data) } else { None }, "File": if self.atype == SendType::File as i32 { Some(&data) } else { None }, - "Key": self.key, + "Key": self.akey, "MaxAccessCount": self.max_access_count, "AccessCount": self.access_count, "Password": self.password_hash.as_deref().map(|h| BASE64URL_NOPAD.encode(h)), diff --git a/src/db/schemas/mysql/schema.rs b/src/db/schemas/mysql/schema.rs index 7f1f4805..346b2959 100644 --- a/src/db/schemas/mysql/schema.rs +++ b/src/db/schemas/mysql/schema.rs @@ -111,7 +111,7 @@ table! { notes -> Nullable, atype -> Integer, data -> Text, - key -> Text, + akey -> Text, password_hash -> Nullable, password_salt -> Nullable, password_iter -> Nullable, diff --git a/src/db/schemas/postgresql/schema.rs b/src/db/schemas/postgresql/schema.rs index 3eb94518..f8e1e9fe 100644 --- a/src/db/schemas/postgresql/schema.rs +++ b/src/db/schemas/postgresql/schema.rs @@ -111,7 +111,7 @@ table! { notes -> Nullable, atype -> Integer, data -> Text, - key -> Text, + akey -> Text, password_hash -> Nullable, password_salt -> Nullable, password_iter -> Nullable, diff --git a/src/db/schemas/sqlite/schema.rs b/src/db/schemas/sqlite/schema.rs index 3eb94518..f8e1e9fe 100644 --- a/src/db/schemas/sqlite/schema.rs +++ b/src/db/schemas/sqlite/schema.rs @@ -111,7 +111,7 @@ table! { notes -> Nullable, atype -> Integer, data -> Text, - key -> Text, + akey -> Text, password_hash -> Nullable, password_salt -> Nullable, password_iter -> Nullable,