File tree Expand file tree Collapse file tree 16 files changed +19
-3
lines changed
crates_io_database_dump/src
migrations/2025-07-16-163013_make_gh_encrypted_token_not_null Expand file tree Collapse file tree 16 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ pub struct User {
2424 #[ serde( skip) ]
2525 pub gh_access_token : SecretString ,
2626 #[ serde( skip) ]
27- pub gh_encrypted_token : Option < Vec < u8 > > ,
27+ pub gh_encrypted_token : Vec < u8 > ,
2828 pub account_lock_reason : Option < String > ,
2929 pub account_lock_until : Option < DateTime < Utc > > ,
3030 pub is_admin : bool ,
@@ -96,7 +96,7 @@ pub struct NewUser<'a> {
9696 pub name : Option < & ' a str > ,
9797 pub gh_avatar : Option < & ' a str > ,
9898 pub gh_access_token : & ' a str ,
99- pub gh_encrypted_token : Option < & ' a [ u8 ] > ,
99+ pub gh_encrypted_token : & ' a [ u8 ] ,
100100}
101101
102102impl NewUser < ' _ > {
Original file line number Diff line number Diff line change @@ -881,7 +881,7 @@ diesel::table! {
881881 /// Whether or not the user wants to receive notifications when a package they own is published
882882 publish_notifications -> Bool ,
883883 /// Encrypted GitHub access token
884- gh_encrypted_token -> Nullable < Bytea > ,
884+ gh_encrypted_token -> Bytea ,
885885 }
886886}
887887
Original file line number Diff line number Diff line change @@ -235,6 +235,7 @@ publish_notifications = "private"
235235gh_encrypted_token = " private"
236236[users .column_defaults ]
237237gh_access_token = " ''"
238+ gh_encrypted_token = " ''"
238239
239240[version_downloads ]
240241dependencies = [" versions" ]
Original file line number Diff line number Diff line change 2424 -- Set defaults for non - nullable columns not included in the dump .
2525
2626 ALTER TABLE " users" ALTER COLUMN " gh_access_token" SET DEFAULT ' ' ;
27+ ALTER TABLE " users" ALTER COLUMN " gh_encrypted_token" SET DEFAULT ' ' ;
2728
2829 -- Truncate all tables .
2930
6768 -- Drop the defaults again .
6869
6970 ALTER TABLE " users" ALTER COLUMN " gh_access_token" DROP DEFAULT ;
71+ ALTER TABLE " users" ALTER COLUMN " gh_encrypted_token" DROP DEFAULT ;
7072
7173 -- Reenable triggers on each table .
7274
Original file line number Diff line number Diff line change 1+ ALTER TABLE users ALTER COLUMN gh_encrypted_token DROP NOT NULL ;
Original file line number Diff line number Diff line change 1+ ALTER TABLE users ALTER COLUMN gh_encrypted_token SET NOT NULL ;
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ mod tests {
107107 . gh_id ( 111 )
108108 . gh_login ( "other_user" )
109109 . gh_access_token ( "token" )
110+ . gh_encrypted_token ( & [ ] )
110111 . build ( )
111112 . insert ( & mut conn)
112113 . await ?;
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ mod tests {
157157 users:: gh_login. eq ( "user1" ) ,
158158 users:: gh_id. eq ( 42 ) ,
159159 users:: gh_access_token. eq ( "some random token" ) ,
160+ users:: gh_encrypted_token. eq ( & [ ] ) ,
160161 ) )
161162 . returning ( users:: id)
162163 . get_result :: < i32 > ( & mut conn)
Original file line number Diff line number Diff line change @@ -707,6 +707,7 @@ mod tests {
707707 . gh_id ( 0 )
708708 . gh_login ( gh_login)
709709 . gh_access_token ( "some random token" )
710+ . gh_encrypted_token ( & [ ] )
710711 . build ( )
711712 . insert ( conn)
712713 . await
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ fn new_user(login: &str) -> NewUser<'_> {
9696 . gh_id ( next_gh_id ( ) )
9797 . gh_login ( login)
9898 . gh_access_token ( "some random token" )
99+ . gh_encrypted_token ( & [ ] )
99100 . build ( )
100101}
101102
You can’t perform that action at this time.
0 commit comments