npx vratix init
Our API modules currently support PostgreSQL for handling data storage, migrations, and seamless integration with your backend. This guide covers configuring PostgreSQL, setting up a local environment, and managing migrations.
Configuration
To configure PostgreSQL as your database engine, ensure you’ve set up your environment file correctly with the following .env
variable:
If you are running the DB as a Docker container, use postgres
as the hostname.
Running with Docker
To spin up a local PostgreSQL database, you can use Docker to avoid manual installation:
-
If Docker is enabled in your project, a
/dbConfig/postgres/docker-compose.yaml
file should already be present with a PostgreSQL service setup, If you haven't created your project using our CLI, you will need to add a Docker Compose file yourself. -
To start the PostgreSQL container, run:
Migrations
Our CLI generates migration files for each module, making it easy to handle your database updates.
NOTE: All of our modules that have a DB repository implementation come with schema and migration files, which are added to your project when installing them.
We add a package.json
file in /src/db-migrations
to enable db-migrate
to work with our ESM project. Do not modify the contents of this file.
To run migrations, execute the following command from your project root:
To create new migration files for your SQL schemas, follow the db-migrate
package guide.
Template Repository
If you select None as your database during CLI setup, a repository template will be added to your project. This template provides a foundation for implementing any database of your choice. The repository pattern abstracts data access logic, making it easy to integrate, replace, or modify for various databases.