Skip to content

Commit d96befd

Browse files
committed
database: Add nullable users.gh_encrypted_token column
1 parent 647a589 commit d96befd

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

crates/crates_io_database/src/models/user.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub struct User {
2323
#[diesel(deserialize_as = String)]
2424
#[serde(skip)]
2525
pub gh_access_token: SecretString,
26+
#[serde(skip)]
27+
pub gh_encrypted_token: Option<Vec<u8>>,
2628
pub account_lock_reason: Option<String>,
2729
pub account_lock_until: Option<DateTime<Utc>>,
2830
pub is_admin: bool,
@@ -94,6 +96,7 @@ pub struct NewUser<'a> {
9496
pub name: Option<&'a str>,
9597
pub gh_avatar: Option<&'a str>,
9698
pub gh_access_token: &'a str,
99+
pub gh_encrypted_token: Option<&'a [u8]>,
97100
}
98101

99102
impl NewUser<'_> {
@@ -125,6 +128,7 @@ impl NewUser<'_> {
125128
users::name.eq(excluded(users::name)),
126129
users::gh_avatar.eq(excluded(users::gh_avatar)),
127130
users::gh_access_token.eq(excluded(users::gh_access_token)),
131+
users::gh_encrypted_token.eq(excluded(users::gh_encrypted_token)),
128132
))
129133
.returning(User::as_returning())
130134
.get_result(conn)

crates/crates_io_database/src/schema.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@ diesel::table! {
880880
is_admin -> Bool,
881881
/// Whether or not the user wants to receive notifications when a package they own is published
882882
publish_notifications -> Bool,
883+
/// Encrypted GitHub access token
884+
gh_encrypted_token -> Nullable<Bytea>,
883885
}
884886
}
885887

crates/crates_io_database_dump/src/dump-db.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ account_lock_reason = "private"
232232
account_lock_until = "private"
233233
is_admin = "private"
234234
publish_notifications = "private"
235+
gh_encrypted_token = "private"
235236
[users.column_defaults]
236237
gh_access_token = "''"
237238

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alter table users drop column gh_encrypted_token;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
alter table users
2+
add column gh_encrypted_token bytea;
3+
4+
comment on column users.gh_encrypted_token is 'Encrypted GitHub access token';

0 commit comments

Comments
 (0)