From 13ed9dc1f135a1d60160aecfe09393b32ae7d32f Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 27 Dec 2021 12:52:15 -0800 Subject: [PATCH] Document database setup and fix issue in script/seed-db Co-Authored-By: Max Brunsfeld --- README.md | 8 ++++++++ crates/server/src/bin/seed.rs | 9 --------- script/seed-db | 7 ++++++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 92ce2bb758..a70aa29637 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,14 @@ cd .. git clone https://github.com/zed-industries/zed.dev ``` +Make sure your local database is created, migrated, and seeded with initial data. Install [Postgres](https://postgresapp.com), then from the `zed` repository root, run: + +``` +script/sqlx database create +script/sqlx migrate run +script/seed-db +``` + Run `zed.dev` and the collaboration server. ``` diff --git a/crates/server/src/bin/seed.rs b/crates/server/src/bin/seed.rs index 4d3fb978db..d5400d0008 100644 --- a/crates/server/src/bin/seed.rs +++ b/crates/server/src/bin/seed.rs @@ -6,18 +6,9 @@ use time::{Duration, OffsetDateTime}; #[allow(unused)] #[path = "../db.rs"] mod db; -#[path = "../env.rs"] -mod env; #[async_std::main] async fn main() { - if let Err(error) = env::load_dotenv() { - log::error!( - "error loading .env.toml (this is expected in production): {}", - error - ); - } - let mut rng = StdRng::from_entropy(); let database_url = std::env::var("DATABASE_URL").expect("missing DATABASE_URL env var"); let db = Db::new(&database_url, 5) diff --git a/script/seed-db b/script/seed-db index f42a33ba00..437d1bcac8 100755 --- a/script/seed-db +++ b/script/seed-db @@ -1,4 +1,9 @@ #!/bin/bash - set -e + +cd crates/server + +# Export contents of .env.toml +eval "$(cargo run --bin dotenv)" + cargo run --package=zed-server --features seed-support --bin seed