added database readme, added file to .gitignore
This commit is contained in:
parent
4104a76f3e
commit
eab3904e69
1
database/.gitignore
vendored
1
database/.gitignore
vendored
@ -0,0 +1 @@
|
||||
.env
|
@ -1,3 +1,43 @@
|
||||
# Database
|
||||
|
||||
TODO
|
||||
You can set environment variables either through the command line, the Nix flake (if you are running nix/NixOS), _or_ the `.env` file
|
||||
|
||||
## Create migration database
|
||||
|
||||
Run:
|
||||
|
||||
```
|
||||
sqlx database create
|
||||
```
|
||||
|
||||
Only run this if the `DATABASE_URL` environment variable is set (with the `postgres://` protocol) and if the database migration has _not_ been set up yet.
|
||||
|
||||
## Create a new migration file
|
||||
|
||||
Run:
|
||||
|
||||
```
|
||||
sqlx migrate add -r <name>
|
||||
```
|
||||
|
||||
where `<name>` is the name of the database file name given.
|
||||
|
||||
This new migration will be placed in the `migrations/` directory.
|
||||
|
||||
## Run the migrations
|
||||
|
||||
Run:
|
||||
|
||||
```
|
||||
sqlx migrate run
|
||||
```
|
||||
|
||||
to run the _all_ migrations.
|
||||
|
||||
To revert migraitons:
|
||||
|
||||
```
|
||||
sqlx migrate revert
|
||||
```
|
||||
|
||||
to rollback (all?) migrations.
|
||||
|
Loading…
Reference in New Issue
Block a user