我按照他们的官方文档开始使用 Diesel 。我也安装了 PostgreSQL。我的数据库用户名是postgres
,密码是1schoollife@
。
我从
$ echo DATABASE_URL=postgres://postgres:1schoollife@@localhost/diesel_demo > .env
$ diesel setup
结果:
Creating migrations directory at: /home/naufil/Desktop/rust/3june/testing/migrations
Creating database: diesel_demo
database "diesel_demo" already exists
我创建了一个迁移:
$ diesel migration generate create_posts
Creating migrations/2019-06-03-182531_create_posts/up.sql
Creating migrations/2019-06-03-182531_create_posts/down.sql
迁移数据库时出现以下错误:
$ diesel migration run
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ConnectionError(BadConnection("could not translate host name \"@localhost\" to address: Name or service not known\n"))', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.