Skip to content

Commit 474e926

Browse files
authored
Merge pull request #550 from integer32llc/postgres-in-readme
Add more documentation about crates.io's database needs
2 parents 5bc3409 + c1db81b commit 474e926

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

README.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,24 @@ yarn run ember test --server
7070
After cloning the repo, steps for setting up the backend API server are as
7171
follows:
7272

73-
1. Copy the `.env.sample` file to `.env` and change any applicable values as
73+
1. Install [Postgres](https://www.postgresql.org/) >= 9.5 and create a
74+
database. For example, if you wanted your database to be named
75+
`cargo_registry`, you can run `psql` to connect to postgres, then run
76+
`CREATE DATABASE cargo_registry;`.
77+
78+
2. Copy the `.env.sample` file to `.env` and change any applicable values as
7479
directed by the comments in the file. Make sure the values in your new
7580
`.env` are exported in the shell you use for the following commands.
7681

77-
2. Set up the git index:
82+
3. Set up the git index:
7883

7984
```
8085
./script/init-local-index.sh
8186
```
8287
8388
But *do not* modify your `~/.cargo/config` yet. Do that after step 3.
8489
85-
3. Build the server:
90+
4. Build the server:
8691
8792
```
8893
cargo build
@@ -91,37 +96,44 @@ follows:
9196
On OS X 10.11, you will need to install the openssl headers first, and tell
9297
cargo where to find them. See https://github.com/sfackler/rust-openssl#osx.
9398
94-
4. Run the migrations:
99+
5. Run the migrations:
95100
96101
```
97102
./target/debug/migrate
98103
```
99104
100-
5. Start the backend server:
105+
6. Start the backend server:
101106
102107
```
103108
./target/debug/server
104109
```
105110
106-
6. **Optionally** start a local frontend:
111+
7. **Optionally** start a local frontend:
107112
108113
```
109114
yarn run start:local
110115
```
111116
112117
### Running Tests
113118
114-
1. Configure the location of the test database. Note that this should just be a
115-
blank database, the test harness will ensure that migrations are run.
119+
1. Configure the location of the test database. Create a database other than
120+
your development database, since running the tests will clear out the data.
121+
For example, to use a database named `cargo_registry_test`, create it in
122+
postgres by running `psql` to connect to postgres, then run
123+
`CREATE DATABASE cargo_registry_test;`. The test harness will ensure that
124+
migrations are run.
125+
126+
In your `.env` file, specify your test database URL. Here's an example,
127+
assuming your test database is named `cargo_registry_test`:
116128
117129
```
118-
export TEST_DATABASE_URL=...
130+
export TEST_DATABASE_URL=postgres://postgres@localhost/cargo_registry_test
119131
```
120132
121-
2. Set the s3 bucket to `alexcrichton-test`. No actual requests to s3 will be
122-
made; the requests and responses are recorded in files in
123-
`tests/http-data` and the s3 bucket name needs to match the requests in the
124-
files.
133+
2. In your `.env` file, set the s3 bucket to `alexcrichton-test`. No actual
134+
requests to s3 will be made; the requests and responses are recorded in
135+
files in `tests/http-data` and the s3 bucket name needs to match the
136+
requests in the files.
125137
126138
```
127139
export S3_BUCKET=alexcrichton-test

0 commit comments

Comments
 (0)