diff --git a/database/.gitignore b/database/.gitignore index e69de29..4c49bd7 100644 --- a/database/.gitignore +++ b/database/.gitignore @@ -0,0 +1 @@ +.env diff --git a/database/README.md b/database/README.md index a096d79..052ddde 100644 --- a/database/README.md +++ b/database/README.md @@ -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 +``` + +where `` 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.