Skip to content

Commit 090ba99

Browse files
authored
database: Drop badges table (#8155)
We haven't returned the data from the API for two years and haven't shown the badges on the frontend for four years, so it's time to get rid of the unused data in the database.
1 parent ae69817 commit 090ba99

File tree

5 files changed

+23
-51
lines changed

5 files changed

+23
-51
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
create table if not exists badges
2+
(
3+
crate_id integer not null
4+
constraint fk_badges_crate_id
5+
references crates
6+
on delete cascade,
7+
badge_type varchar not null,
8+
attributes jsonb not null,
9+
primary key (crate_id, badge_type)
10+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
drop table badges;

src/schema.patch

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
diff --git a/src/schema.rs b/src/schema.rs
2-
index bb2658942..1bc6801ea 100644
3-
--- a/src/schema.rs
4-
+++ b/src/schema.rs
5-
@@ -14,9 +14,7 @@ pub mod sql_types {
1+
@@ -21,9 +21,7 @@
62
/// The `pg_catalog.tsvector` SQL type
73
///
84
/// (Automatically generated by Diesel.)
@@ -13,7 +9,7 @@ index bb2658942..1bc6801ea 100644
139
}
1410

1511
diesel::table! {
16-
@@ -67,9 +65,9 @@ diesel::table! {
12+
@@ -74,9 +72,9 @@
1713
/// (Automatically generated by Diesel.)
1814
revoked -> Bool,
1915
/// NULL or an array of crate scope patterns (see RFC #2947)
@@ -25,7 +21,7 @@ index bb2658942..1bc6801ea 100644
2521
/// The `expired_at` column of the `api_tokens` table.
2622
///
2723
/// Its SQL type is `Nullable<Timestamp>`.
28-
@@ -193,12 +191,6 @@ diesel::table! {
24+
@@ -180,12 +178,6 @@
2925
///
3026
/// (Automatically generated by Diesel.)
3127
created_at -> Timestamp,
@@ -38,7 +34,7 @@ index bb2658942..1bc6801ea 100644
3834
}
3935
}
4036

41-
@@ -471,7 +463,7 @@ diesel::table! {
37+
@@ -456,7 +448,7 @@
4238
/// Its SQL type is `Array<Nullable<Text>>`.
4339
///
4440
/// (Automatically generated by Diesel.)
@@ -47,11 +43,10 @@ index bb2658942..1bc6801ea 100644
4743
/// The `target` column of the `dependencies` table.
4844
///
4945
/// Its SQL type is `Nullable<Varchar>`.
50-
@@ -675,6 +667,24 @@ diesel::table! {
51-
}
46+
@@ -683,6 +675,24 @@
5247
}
5348

54-
+diesel::table! {
49+
diesel::table! {
5550
+ /// Representation of the `recent_crate_downloads` view.
5651
+ ///
5752
+ /// This data represents the downloads in the last 90 days.
@@ -69,11 +64,12 @@ index bb2658942..1bc6801ea 100644
6964
+ }
7065
+}
7166
+
72-
diesel::table! {
67+
+diesel::table! {
7368
/// Representation of the `reserved_crate_names` table.
7469
///
75-
@@ -988,7 +998,8 @@ diesel::joinable!(api_tokens -> users (user_id));
76-
diesel::joinable!(badges -> crates (crate_id));
70+
/// (Automatically generated by Diesel.)
71+
@@ -997,7 +1007,8 @@
72+
diesel::joinable!(api_tokens -> users (user_id));
7773
diesel::joinable!(crate_owner_invitations -> crates (crate_id));
7874
diesel::joinable!(crate_owners -> crates (crate_id));
7975
-diesel::joinable!(crate_owners -> users (created_by));
@@ -82,15 +78,15 @@ index bb2658942..1bc6801ea 100644
8278
diesel::joinable!(crates_categories -> categories (category_id));
8379
diesel::joinable!(crates_categories -> crates (crate_id));
8480
diesel::joinable!(crates_keywords -> crates (crate_id));
85-
@@ -1001,6 +1012,7 @@ diesel::joinable!(follows -> users (user_id));
81+
@@ -1010,6 +1021,7 @@
8682
diesel::joinable!(publish_limit_buckets -> users (user_id));
8783
diesel::joinable!(publish_rate_overrides -> users (user_id));
8884
diesel::joinable!(readme_renderings -> versions (version_id));
8985
+diesel::joinable!(recent_crate_downloads -> crates (crate_id));
9086
diesel::joinable!(version_downloads -> versions (version_id));
9187
diesel::joinable!(version_owner_actions -> api_tokens (api_token_id));
9288
diesel::joinable!(version_owner_actions -> users (user_id));
93-
@@ -1027,6 +1039,7 @@ diesel::allow_tables_to_appear_in_same_query!(
89+
@@ -1036,6 +1048,7 @@
9490
publish_limit_buckets,
9591
publish_rate_overrides,
9692
readme_renderings,

src/schema.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -134,32 +134,6 @@ diesel::table! {
134134
}
135135
}
136136

137-
diesel::table! {
138-
/// Representation of the `badges` table.
139-
///
140-
/// (Automatically generated by Diesel.)
141-
badges (crate_id, badge_type) {
142-
/// The `crate_id` column of the `badges` table.
143-
///
144-
/// Its SQL type is `Int4`.
145-
///
146-
/// (Automatically generated by Diesel.)
147-
crate_id -> Int4,
148-
/// The `badge_type` column of the `badges` table.
149-
///
150-
/// Its SQL type is `Varchar`.
151-
///
152-
/// (Automatically generated by Diesel.)
153-
badge_type -> Varchar,
154-
/// The `attributes` column of the `badges` table.
155-
///
156-
/// Its SQL type is `Jsonb`.
157-
///
158-
/// (Automatically generated by Diesel.)
159-
attributes -> Jsonb,
160-
}
161-
}
162-
163137
diesel::table! {
164138
use diesel::sql_types::*;
165139
use super::sql_types::Ltree;
@@ -1031,7 +1005,6 @@ diesel::table! {
10311005
}
10321006

10331007
diesel::joinable!(api_tokens -> users (user_id));
1034-
diesel::joinable!(badges -> crates (crate_id));
10351008
diesel::joinable!(crate_owner_invitations -> crates (crate_id));
10361009
diesel::joinable!(crate_owners -> crates (crate_id));
10371010
diesel::joinable!(crate_owners -> teams (owner_id));
@@ -1060,7 +1033,6 @@ diesel::joinable!(versions_published_by -> versions (version_id));
10601033
diesel::allow_tables_to_appear_in_same_query!(
10611034
api_tokens,
10621035
background_jobs,
1063-
badges,
10641036
categories,
10651037
crate_owner_invitations,
10661038
crate_owners,

src/worker/jobs/dump_db/dump-db.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ last_retry = "private"
3939
created_at = "private"
4040
priority = "private"
4141

42-
[badges]
43-
dependencies = ["crates"]
44-
[badges.columns]
45-
crate_id = "public"
46-
badge_type = "public"
47-
attributes = "public"
48-
4942
[categories.columns]
5043
id = "public"
5144
category = "public"

0 commit comments

Comments
 (0)