RyzeDeskRyzeDesk

Personal

27 articles

Configuring the Database


Setting up and configuring the database for the Gas API is essential for managing billing, provisioning, and integration of nodes and devices. This guide will help you configure the database to ensure your API functions correctly.

Before you start

  • Install Go dependencies.
  • Have access to the database server.
  • Ensure you have the necessary permissions to modify database settings.

Steps to configure the database

  1. Install Go Dependencies: Make sure all Go dependencies are installed. You can do this by running go mod tidy in your project directory.

  2. Prepare the Database: Access your database server and ensure it is running. You may need to create a new database specifically for the Gas API.

  3. Apply Migrations: Use the provided migration files to set up the database schema. Run each migration in order, starting with the initial setup:

    • Navigate to the directory containing the migration files.
    • Execute the migrations using a tool like migrate or directly through your database client.
  4. Configure Database Connection: Open the configuration file for the Gas API and locate the database connection settings. Modify these settings to match your database server details, such as host, port, username, password, and database name.

  5. Test the Connection: Once configured, test the database connection to ensure it is working correctly. You can do this by running a simple query or using a health check endpoint if available.

  6. Deploy the Application: With the database configured, deploy the Gas API application. Ensure it connects to the database without errors.

Example Configuration

Below is an example of what your database configuration might look like in a configuration file:

database:
  host: "localhost"
  port: 5432
  username: "your_username"
  password: "your_password"
  dbname: "gas_api_db"

If something goes wrong

  • Connection Error: If you encounter a connection error, double-check your database host, port, username, and password. Ensure the database server is running and accessible.

  • Migration Failure: If a migration fails, verify that the migration files are in the correct order and that there are no syntax errors. Check the database logs for specific error messages.

  • Application Fails to Start: If the application does not start, review the application logs for any database-related errors. Ensure all dependencies are correctly installed and configured.

Last verified 2026-09-20