Database Queries
The backend depends on sqlx for interfacing with the PostgreSQL database. sqlx is not an ORM so we rely on basic SQL queries to query data. To do so in a maintainable way we almost exclusivly use compile time verified queries.
This is only required if you are modifying already existing queries or adding new ones.
This requires sqlx to connect to a database that contains the applications latest schema.
You can specify the database to connect to with the DATABASE_URL
environment variable.
export DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres"
To be able to build the application without a database, you'll need to run cargo sqlx prepare
.
This command is provided by the sqlx-cli
and stores metadata in a .sqlx
directory.
This directory needs to be then checked into version control alongside you queries and other modified code.
If you don't the build pipeline will fail.