added database readme, added file to .gitignore

This commit is contained in:
Wyatt J. Miller 2024-12-06 14:12:05 -05:00
parent 4104a76f3e
commit eab3904e69
2 changed files with 42 additions and 1 deletions

1
database/.gitignore vendored
View File

@ -0,0 +1 @@
.env

View File

@ -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.