@@ -33,17 +33,24 @@ CREATE TABLE users (
3333DROP TABLE USERS;
3434```
3535
36- You can then run your new migration by running ` diesel migration run ` . Make
37- sure that you set the ` DATABASE_URL ` environment variable first, or pass it
38- directly by doing `diesel migration run
39- --database-url="postgres://localhost/your_database"` Alternatively, you can
40- call [ ` diesel::migrations::run_pending_migrations ` ] [ pending-migrations ] from
36+ You can then run your new migration by running ` diesel migration run ` . Your
37+ DATABASE_URL must be set in order to run this command, and there are serveral
38+ ways that you can set it:
39+
40+ * Set it as an environment variable manually
41+ * Set it as an environment variable using [ rust-dotenv] [ rust-dotenv ]
42+ * Pass it directly by adding the ` --database-url ` flag
43+
44+ As an alternative to running migrations with the CLI, you can call
45+ [ ` diesel::migrations::run_pending_migrations ` ] [ pending-migrations ] from
4146` build.rs ` .
4247
4348Diesel will automatically keep track of which migrations have already been run,
4449ensuring that they're never run twice.
4550
46- ## Commands
51+ Commands
52+ --------
53+
4754## ` diesel setup `
4855Searches for a ` migrations/ ` directory, and if it can't find one, creates one
4956in the same directory as the first ` Cargo.toml ` it finds. It then tries to
@@ -81,3 +88,4 @@ Runs the `down.sql` for the most recent migration.
8188Runs the ` down.sql ` and then the ` up.sql ` for the most recent migration.
8289
8390[ pending-migrations ] : http://sgrif.github.io/diesel/diesel/migrations/fn.run_pending_migrations.html
91+ [ rust-dotenv ] : https://github.com/slapresta/rust-dotenv#examples
0 commit comments