Skip to content

Commit 65be740

Browse files
committed
db: Add default_versions.total column
1 parent a1cfc11 commit 65be740

File tree

6 files changed

+13
-2
lines changed

6 files changed

+13
-2
lines changed

crates/crates_io_database/src/schema.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ diesel::table! {
408408
crate_id -> Int4,
409409
/// Reference to the version in the `versions` table.
410410
version_id -> Int4,
411+
/// The total number of versions.
412+
total -> Int4,
411413
}
412414
}
413415

crates/crates_io_database_dump/src/dump-db.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ dependencies = ["crates", "versions"]
105105
[default_versions.columns]
106106
crate_id = "public"
107107
version_id = "public"
108+
total = "public"
108109

109110
[deleted_crates]
110111
dependencies = ["users"]

crates/crates_io_database_dump/src/snapshots/[email protected]

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
source: crates/crates_io_database_dump/src/lib.rs
33
expression: content
4+
snapshot_kind: text
45
---
56
BEGIN ISOLATION LEVEL REPEATABLE READ, READ ONLY;
67

@@ -18,7 +19,7 @@ BEGIN ISOLATION LEVEL REPEATABLE READ, READ ONLY;
1819
\copy (SELECT "crate_id", "created_at", "created_by", "owner_id", "owner_kind" FROM "crate_owners" WHERE NOT deleted) TO 'data/crate_owners.csv' WITH CSV HEADER
1920

2021
\copy "versions" ("bin_names", "categories", "checksum", "crate_id", "crate_size", "created_at", "description", "documentation", "downloads", "edition", "features", "has_lib", "homepage", "id", "keywords", "license", "links", "num", "num_no_build", "published_by", "repository", "rust_version", "updated_at", "yanked") TO 'data/versions.csv' WITH CSV HEADER
21-
\copy "default_versions" ("crate_id", "version_id") TO 'data/default_versions.csv' WITH CSV HEADER
22+
\copy "default_versions" ("crate_id", "total", "version_id") TO 'data/default_versions.csv' WITH CSV HEADER
2223
\copy "dependencies" ("crate_id", "default_features", "explicit_name", "features", "id", "kind", "optional", "req", "target", "version_id") TO 'data/dependencies.csv' WITH CSV HEADER
2324
\copy "version_downloads" ("date", "downloads", "version_id") TO 'data/version_downloads.csv' WITH CSV HEADER
2425
COMMIT;

crates/crates_io_database_dump/src/snapshots/[email protected]

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
source: crates/crates_io_database_dump/src/lib.rs
33
expression: content
4+
snapshot_kind: text
45
---
56
BEGIN;
67
-- Disable triggers on each table.
@@ -60,7 +61,7 @@ BEGIN;
6061
\copy "crates_keywords" ("crate_id", "keyword_id") FROM 'data/crates_keywords.csv' WITH CSV HEADER
6162
\copy "crate_owners" ("crate_id", "created_at", "created_by", "owner_id", "owner_kind") FROM 'data/crate_owners.csv' WITH CSV HEADER
6263
\copy "versions" ("bin_names", "categories", "checksum", "crate_id", "crate_size", "created_at", "description", "documentation", "downloads", "edition", "features", "has_lib", "homepage", "id", "keywords", "license", "links", "num", "num_no_build", "published_by", "repository", "rust_version", "updated_at", "yanked") FROM 'data/versions.csv' WITH CSV HEADER
63-
\copy "default_versions" ("crate_id", "version_id") FROM 'data/default_versions.csv' WITH CSV HEADER
64+
\copy "default_versions" ("crate_id", "total", "version_id") FROM 'data/default_versions.csv' WITH CSV HEADER
6465
\copy "dependencies" ("crate_id", "default_features", "explicit_name", "features", "id", "kind", "optional", "req", "target", "version_id") FROM 'data/dependencies.csv' WITH CSV HEADER
6566
\copy "version_downloads" ("date", "downloads", "version_id") FROM 'data/version_downloads.csv' WITH CSV HEADER
6667

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE default_versions
2+
DROP COLUMN total;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE default_versions
2+
ADD COLUMN total INTEGER NOT NULL default 0;
3+
4+
COMMENT ON COLUMN default_versions.total IS 'The total number of versions.';

0 commit comments

Comments
 (0)