File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,40 @@ $ sqlx migrate run
4949Compares the migration history of the running database against the ` migrations/ ` folder and runs
5050any scripts that are still pending.
5151
52+ #### Reverting Migrations
53+
54+ If you would like to create _ reversible_ migrations with corresponding "up" and "down" scripts, you use the ` -r ` flag when creating new migrations:
55+
56+ ``` bash
57+ $ sqlx migrate add -r < name>
58+ Creating migrations/20211001154420_< name> .up.sql
59+ Creating migrations/20211001154420_< name> .down.sql
60+ ```
61+
62+ After that, you can run these as above:
63+
64+ ``` bash
65+ $ sqlx migrate run
66+ Applied migrations/20211001154420 < name> (32.517835ms)
67+ ```
68+
69+ And reverts work as well:
70+
71+ ``` bash
72+ $ sqlx migrate revert
73+ Applied 20211001154420/revert < name>
74+ ```
75+
76+ ** Note** : attempting to mix "simple" migrations with reversible migrations with result in an error.
77+
78+ ``` bash
79+ $ sqlx migrate add < name1>
80+ Creating migrations/20211001154420_< name> .sql
81+
82+ $ sqlx migrate add -r < name2>
83+ error: cannot mix reversible migrations with simple migrations. All migrations should be reversible or simple migrations
84+ ```
85+
5286#### Enable building in "offline mode" with ` query!() `
5387
5488Note: must be run as ` cargo sqlx ` .
You can’t perform that action at this time.
0 commit comments