Skip to content

Commit 3acb400

Browse files
authored
database/api_tokens: Add crate_scopes and endpoint_scopes columns (#5562)
1 parent 0a43619 commit 3acb400

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
alter table api_tokens
2+
drop column crate_scopes;
3+
4+
alter table api_tokens
5+
drop column endpoint_scopes;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
alter table api_tokens
2+
add column crate_scopes text[];
3+
4+
comment on column api_tokens.crate_scopes is 'NULL or an array of crate scope patterns (see RFC #2947)';
5+
6+
alter table api_tokens
7+
add column endpoint_scopes text[];
8+
9+
comment on column api_tokens.endpoint_scopes is 'An array of endpoint scopes or NULL for the `legacy` endpoint scope (see RFC #2947)';

src/models/token.rs

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ pub struct ApiToken {
2323
pub last_used_at: Option<NaiveDateTime>,
2424
#[serde(skip)]
2525
pub revoked: bool,
26+
/// `None` or a list of crate scope patterns (see RFC #2947)
27+
#[serde(skip)]
28+
pub crate_scopes: Option<Vec<String>>,
29+
/// A list of endpoint scopes or `None` for the `legacy` endpoint scope (see RFC #2947)
30+
#[serde(skip)]
31+
pub endpoint_scopes: Option<Vec<String>>,
2632
}
2733

2834
impl ApiToken {
@@ -106,6 +112,8 @@ mod tests {
106112
.and_hms_opt(14, 23, 12),
107113
)
108114
.unwrap(),
115+
crate_scopes: None,
116+
endpoint_scopes: None,
109117
};
110118
let json = serde_json::to_string(&tok).unwrap();
111119
assert_some!(json

src/schema.rs

+12
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ table! {
5050
///
5151
/// (Automatically generated by Diesel.)
5252
revoked -> Bool,
53+
/// The `crate_scopes` column of the `api_tokens` table.
54+
///
55+
/// Its SQL type is `Nullable<Array<Text>>`.
56+
///
57+
/// (Automatically generated by Diesel.)
58+
crate_scopes -> Nullable<Array<Text>>,
59+
/// The `endpoint_scopes` column of the `api_tokens` table.
60+
///
61+
/// Its SQL type is `Nullable<Array<Text>>`.
62+
///
63+
/// (Automatically generated by Diesel.)
64+
endpoint_scopes -> Nullable<Array<Text>>,
5365
}
5466
}
5567

src/worker/dump_db/dump-db.toml

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ name = "private"
2626
created_at = "private"
2727
last_used_at = "private"
2828
revoked = "private"
29+
crate_scopes = "private"
30+
endpoint_scopes = "private"
2931

3032
[background_jobs.columns]
3133
id = "private"

0 commit comments

Comments
 (0)