File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # Downloads the database dump tarball from crates.io and imports it
4
+ # into the `cargo_registry` database. If the database already exists it
5
+ # is recreated from scratch!
6
+
7
+ set -o errexit
8
+ set -o nounset
9
+ set -o pipefail
10
+
11
+ readonly TARBALL_PATH=" tmp/db-dump.tar.gz"
12
+ readonly DUMP_PATH=" tmp/db-dump"
13
+
14
+ if [ -f " $TARBALL_PATH " ]; then
15
+ echo " Skipping https://static.crates.io/db-dump.tar.gz download since it exists already "
16
+ else
17
+ echo " Downloading https://static.crates.io/db-dump.tar.gz to the 'tmp' folder"
18
+ curl https://static.crates.io/db-dump.tar.gz --output $TARBALL_PATH
19
+ fi
20
+
21
+ if [ -d " $DUMP_PATH " ]; then
22
+ echo " Skipping db-dump.tar.gz extraction since '$DUMP_PATH ' exists already"
23
+ else
24
+ echo " Extracting db-dump.tar.gz to '$DUMP_PATH '"
25
+ mkdir -p $DUMP_PATH
26
+ tar -xf $TARBALL_PATH --strip 1 -C $DUMP_PATH
27
+ fi
28
+
29
+ cd $DUMP_PATH
30
+ echo " Creating 'cargo_registry' database"
31
+ psql --command=" DROP DATABASE IF EXISTS cargo_registry"
32
+ psql --command=" CREATE DATABASE cargo_registry"
33
+
34
+ echo " Importing database schema"
35
+ psql -a cargo_registry < schema.sql
36
+
37
+ echo " Importing data"
38
+ psql -a cargo_registry < import.sql
You can’t perform that action at this time.
0 commit comments