my-website-v2/database
2024-12-06 14:12:05 -05:00
..
migrations added intial migration 2024-09-29 21:15:56 -04:00
.gitignore added database readme, added file to .gitignore 2024-12-06 14:12:05 -05:00
README.md added database readme, added file to .gitignore 2024-12-06 14:12:05 -05:00

Database

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.