@@ -13,7 +13,8 @@ diesel setup --database-url='postgres://localhost/my_db'
1313diesel migration generate create_users_table
1414```
1515
16- You'll see that two files were generated for you,
16+ You'll see that a ` migrations/ ` directory was generated for you (by the setup
17+ command), and two sql files were generated,
1718` migrations/{current_timestamp}_create_users_table/up.sql ` and
1819` migrations/{current_timestamp}_create_users_table/down.sql ` . You should edit
1920these files to show how to update your schema, and how to undo that change.
@@ -32,25 +33,37 @@ CREATE TABLE users (
3233DROP TABLE USERS;
3334```
3435
35- You can then run your new migration by running ` diesel migration run ` . Make sure
36- that you set the ` DATABASE_URL ` environment variable first, or pass it directly
37- by doing ` diesel migration run --database-url="postgres://localhost/your_database" `
38- Alternatively, you can call
39- [ ` diesel::migrations::run_pending_migrations ` ] [ pending-migrations ] from
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
4041` build.rs ` .
4142
4243Diesel will automatically keep track of which migrations have already been run,
4344ensuring that they're never run twice.
4445
45- ### Commands
46- #### ` setup `
46+ ## Commands
47+ ## ` diesel setup`
4748Searches for a ` migrations/ ` directory, and if it can't find one, creates one
4849in the same directory as the first ` Cargo.toml ` it finds. It then tries to
4950connect to the provided DATABASE_URL, and will create the given database if it
5051cannot connect to it. Finally it will create diesel's internal table for
5152tracking which migrations have been run, and run any existing migrations if the
5253internal table did not previously exist.
5354
55+ ## ` diesel database `
56+ #### ` database setup `
57+ Tries to connect to the provided DATABASE_URL, and will create the given
58+ database if it cannot connect to it. It then creates diesel's internal
59+ migrations tracking table if it needs to be created, and runs any pending
60+ migrations if it created the internal table.
61+
62+ #### ` database reset `
63+ Drops the database specified in your DATABASE_URL if it can, and then runs
64+ ` database database setup ` .
65+
66+ ## ` diesel migration `
5467#### ` migration generate `
5568Takes the name of your migration as an argument, and will create a migration
5669directory with ` migrations/ ` in the format of
0 commit comments